Saturday, November 8, 2014

Extract sets of compressed tarballs within each respective folder

$ for i in *.gz;  do mkdir `echo $i | cut -d '.' -f1`;  tar xvfz $i -C ./`echo $i | cut -d '.' -f1`; done

The above will:
1) Build a list of all .gz files within the current folder (assuming .tar.gz files)
2) If the tarball filename is tarballfile.tar.gz, create a folder called tarballfile/
3) Extract the contents of tarballfile.tar.gz into folder ./tarballfile/
4) Continue iterating through the other tarball files until the loop has completed.


No comments:

Post a Comment