I have about 200,000 thumbs in a folder that are all gzipped ending with .tar.gz What I am looking to do is extract all the files in that folder but to a different folder. Does anyone know a command to do this? I found this online but I wouldnt know how to use it to extract to a different folder.
for i in *.tar.gz; do tar -xvzf $i; done
Now, if you want a single file or folder from the “tar” file, you need to use the name of the “tar” file and the path to a single file in it. So, we have used the “tar” command with the “-xvf” option, the name of the “tar” file, and the path of a file to be extracted from it as below.
how can I extract multiple gzip files in directory and subdirectories? It will extract all files with their original names and store them in the current user home directory( /home/username ). gunzip *. gz // This command also will work.
Add the -C
option to select the target directory:
for i in *.tar.gz; do tar xvzf $i -C path/to/output/directory; done
Right now you are using
tar
to extract all the files. I believe that you can set which directory to output to.
It would be something like this:
for i in *.tar.gz; do tar -xvzf $i -C directory; done
where directory is the path of the folder you want to extract the files to.
Refer to http://www.computerhope.com/unix/utar.htm (documentation on tar).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With