bzip2 and tar gz all files in a directory
·1 min
For all commands below:
sudo apt-get install moreutils
or on Mac OS X
brew install moreutils
To bzip2
all files in a directory #
- cd to directory
find "$PWD" -type f ! -regex '.*\(bz2\)$' -print0 | ifne xargs -0 bzip2
To tar gzip
all directories in a given directory #
- cd to directory
for i in ./*; do test -d "$i" || continue; tar -zcvf "$i".tar.gz "$i"; done
To decompress all bzip2
in a given directory #
- cd to directory
find "$PWD" -type f -regex '.*\(bz2\)$' -print0 | ifne xargs -0 bzip2 -d
To unzip all gzipped
tars in a directory #
- cd to directory
tar -xzvf *.tar.gz