Following bash script will generate a tar archive per subdirectory found within a given directory.
1 2 3 4 5 |
for dir in */ do base=$(basename "$dir") tar -czf "${base}.tar.gz" "$dir" done |
Write this code in a .sh file (i.e archive.sh ). Put it in your desired root directory. Execute the .sh using ./archive.sh command.