tar and gzip (tar.gz) all directories individually in a folder

A quick and simple one-liner:

for i in $(ls -d */); do FOLDER=${i%%/}; tar -cvzf $FOLDER.tar.gz $FOLDER && rm -rf $FOLDER; done

Leave a Reply

Your email address will not be published.