

Please don’t reply with tar -zxvf *.tar.gz (because that does not work) and only reply with “doesn’t work” if you’re absolutely sure about it (and maybe have a good explanation why, too).Įdit: I was pointed to an answer to this question on Stack Overflow which says in great detail that it’s not possible without breaking current tar syntax, but I don’t think that’s true.
Untar .gz file how to#
Now run the following command in the command line of Terminal: gunzip filename.gz. Most of the Linux files that can be downloaded from the Internet are compressed with a tar, tar.gz and tar.bz2 compression formats and it is important to know how to extract such files.


For example, if your file is in /xyz/Documents, then type this command followed by Enter: cd /xyz/documents. someone knows how to use the -M parameter that tar suggested to me when I tried tar -zxv -f a.tgz -f b.tgz In the Terminal window, use the 'cd' command to take you to the specific folder where your gz file is present.While you can find them with a double extension (.tar.gz), the extension can also be shortened to. These files are often referred to as tarballs.

Untar .gz file archive#
I’m an experienced Unix user for several years and of course I know that you can use for or find or things like that to call tar once for each archive you want to extract, but I couldn’t come up with a working command line that caused my tar to extract two. tar.gz, you can use the Convert feature in Archiver and choose TAR.GZ among the options. Use Space to preview your file in Quick Look. * GNU bash, version 4.3.I was wondering whether (and, of course, how) it’s possible to tell tar to extract multiple files in a single run. To unzip GZ file with Archiver: Launch Archiver. I tested these snippets using or in: * Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt9-3 () x86_64 GNU/Linux $ for program in tar unzip untar do # You could simply add to this list. You could use variants of this for loop, if you like adventure :-) # In case of compressed files inside compressed files this will Now we will extract the contents of documents.tgz file to separate /tmp/tgz/ directory. Use a looping construct to decompress each file.ĭecompress all files in the current directory: $ for file in `ls -1` doĭecompress all archives in the current directory and any subdirectories (my personal favorite): $ for file in `find *` doĭecompress all archives recursively and do the same again for any remaining: # Make the above loop a function to be called more than once First make sure that you create the specific directory that you want to extract into by using: mkdir -p /tmp/tgz. Use bash and the utility find to output to the console a list of all contents from the present directory. You want to decompress all compressed files inside a directory and all its subdirectories.
