Decompress tar file
You can find me here on Twitter. Do share your thoughts. If you read this far, tweet to the author to show them you care. Tweet a thanks. Learn to code for free. Get started. Forum Donate. Zaira Hira. What is the tar command? The syntax is shown below: tar [flags] destinationFileName sourceFileName The tar command uses the following flags to customize the command input: Flag Explanation Usage -c Create a new archive.
We use this flag whenever we need to create a new archive. When we specify this flag, it means that archive will be created using gzip compression. Providing the -v flag shows details of the files compressed.
Archive file names are mapped using the -f flag. We use this flag when files need to be extracted from an archive.
How to create an archive We have a list of the following files which we'll compress with tar. List of files to be compressed. The output confirms that the file now has a. When you run gzip on multiple files at once, the system generates a compressed copy of each file.
This can clutter up a directory quickly! It is an archive file with several other files inside it, which is then compressed. To instruct tar to put the extracted unzipped files into a specific directory, enter:. The addition of the —z option is what signals tar to compress the files. This copies the contents of your Documents folder into a single file, called documents. The options -cvf work as follows:. This command extracts and lists all files from the documents.
The -x option tells tar to extract the files. You can also use xargs with tar to create a tar. Note: Some graphical interfaces include a tool for managing tar.
Simply right-click the item you want to compress, mouseover compress, and choose tar. Firstly, we have -h which though not required in this particular case, I highly recommend to always include in your tar commands. This option stands for dereference , which will dereference or follow symlinks, archiving and dumping the files they point to. Next we have the -c and -f options.
Note that they are just written together with the - in -h , i. Quick and easy. The -c option stand for create a new archive. Note that by default directories are archived recursively, unless a —no-recursion option is also used. The -f option allows us to specify the name of the archive. It thus has to come last in our option chain as it requires an option so we can add the archive file name directly behind it. Using tar -fch test. After the tar is generated, we use a modified ls output which clearly shows us the number of bytes per file.
As you can see, the tar file is much larger then all of our files combined. The files are simply being archived and some overall overhead for tar is being added. As an interesting sidenote, we can also see what types of files were are working with by simply using the file command at the command prompt:. A very common compression algorithm is GZIP. We also included the -z option which will use GZIP compression to compress the resulting.
0コメント