I accidently gzip -rv directory
and now all individual files is in .gz format. How do I undo this and gunzip all .gz files within the directory
?
And how do I just gzip this whole directory?
I tried gunzip directory/*.gz
but only gunzip the files in directory/ it doesn't gunzip directory beyond "directory".
To unzip your files, do the following:
This will unzip all files with the name *.gz
find
can find under the directory/yourdirectory
.For gzipping a whole directory, you need a
tar
container, as gzip can only compress individual files:If you want the (much slower but much more effective) bzip2 compression, use the
j
instead thez
parameter:Both commands will create a compressed archive, there is no need to do an additional compression step afterwards.
This would do the trick:
Tar the directory first with
tar -cf myarchive.tar myarchive/
and compress it afterwards withgzip myarchive.tar
.You can unpack this afterwards with
tar -xvf myarchive.tar.gz
with newer versions of tar. With older versions you should add use-xvzf
instead