Using Tar to compress all directories individually

I had to do this recently for a project, I required each subdirectory within a directory to be individually compressed into a separate archive with the same name as the original directory for transfer to another host.

cd /the/required/top-directory/
for dir in $(ls -d *); do tar -czf "$dir.tar.gz" "$dir"; done

Any comments or questions? Get in touch here or Email me at [email protected]