While tar is frequently used to compress a single directory, you could also use it to compress multiple directories, multiple individual files , or both. Just provide a list of files or directories instead of a single one.
In some cases, you may wish to compress an entire directory, but not include certain files and directories. You can do so by appending an --exclude switch for each directory or file you want to exclude.
The --exclude switch is very powerful. For example, you could archive an entire directory and exclude all. While gzip compression is most frequently used to create. This allows you to create bzip2-compressed files, often named. To do so, just replace the -z for gzip in the commands here with a -j for bzip2. Gzip is faster, but it generally compresses a bit less, so you get a somewhat larger file.
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. In the results below, we can see that the archive has been created successfully. Archive has been created with supplied command.
How to remove files after compression Let's say we don't want to keep the original files after creating an archive. How to view the contents of an archive You might need to view the contents of an archive without actually extracting it. Viewing contents of an archive. Extracting an archive. Use tar to combine multiple files into an archive file On this page:. If you don't use the -f option, tar will assume you want to create a tape archive instead of combining a number of files.
The -v option tells tar to be verbose report all files as they are added. In the above examples, the -z option tells tar to use gzip to compress the archive as it is created. The file extensions. Related documents. About the. Z file extension Make better use of your disk space in Unix About compressed files in Unix Combine several text files into a single file in Unix.
0コメント