Tar multiple folders

·

1 min read

CASE 1:** Consider you have three folders as below: ➜ simulator ls folder1C folder2C folder3C

Now if you want to zip all these :

tar -czvf simulator.tar.gz folder1C folder2C folder3C

To untar

tar -xvf simulator.tar.gz folder1C folder2C folder3C

CASE 2:**

Consider if you have list of directories obtained by grep. Then you can use below to create a tar file

ls | grep folder  | grep -v tar.gz | xargs tar -czvf simulator1.tar.gz

Above example excludes tar files already present in the folder and compresses other files with folder in name