Let us take, for example, a directory named results and create from it an archive file named results.tar. Perhaps the most common use of tar is to create an archive of a single directory. Your working directory may look very different but the idea is the same and this directory is used as a working example.Īrchiving files and directories Archiving a directory To illustrate the use of archiving and compressing utilities, we use a working directory that contains the following sub-directories and files. Note in particular that some older systems might not support -xz compression. You can get a complete list of the options available on your system with man tar or tar -help. There are many more options for tar, but these may depend on the version you are using. Tar -cJf project1 is equivalent to tar -create -xz -file= project1. Single-letter options can be combined with a single dash, so for example: -z or -gzip: Compress or decompress with gzip.-J or -xz: Compress or decompress with xz.-t or -list: List the content of an archive file.-x or -extract: Extract files from archive.-f or -file=: Following is the archive file name.There are two synonymous forms for each, a single-letter form prefixed with a single dash, and a whole-word form prefixed with a double dash: Here are the most common options for this command. These commands will produce the files and 2. The compressing utilities are used as gzip bzip2 project1.tar Once a tar file is created, it is also possible to use gzip or bzip2 to compress the archive and reduce its size. Similarly, you can run xz -d or gzip -d to decompress an archive file before running tar -extract, but again this is seldom necessary. You can also run tar -create first without compression and then use the commands xz or gzip in a separate step, although there is seldom a reason to do so. gzip does not typically compress as much, but may be used if you encounter difficulties due to insufficient memory or excessive run time during tar -create. with a better compression ratio) but takes longer and uses more RAM while working. Typically, -xz produces a smaller compressed file (i.e. We recommend either xz or gzip, which can be used as tar -create -xz -file tar -extract -xz -file tar -create -gzip -file tar -extract -gzip -file There are a number of compression methods to choose from. The tar archiving utility can compress an archive file at the same time it creates it. Another option can be added to specify the destination directory where to extract the archive's content. If a directory of that name exists and contains files of the same names as in the archive file, they will be overwritten. If there is no directory with the original name, it will be created. You can extract files from an archive file using the same command with a different option: tar -extract -file project1.tar. The original directory will remain unchanged, so this may double the amount of disk space occupied! So the command tar -create -file project1.tar project1 will pack all the content of directory project1 into the file project1.tar. When you archive a directory with tar, it will, by default, include all the files and sub-directories contained within it, and sub-sub-directories contained in those, and so on. It will bundle several files or directories and generate a single file called an archive file or tar file, or humorously a tarball. The primary archiving utility on Linux and Unix-like systems is the tar command. Using tar to archive files and directories 5.1 Size of a file, directory or archive.4.4.3 Listing the contents of a compressed file (*.gz or.4.4.2 Searching for a file in an archive file without unpacking it.4.3.5 Extract multiple files using wildcards.4.3.4 Extracting one file from an archive or a compressed archive.4.3.3 Extracting a compressed archive file into another directory.4.3 Unpacking compressed files and archives.4.2.2 Adding files to a compressed archive (tar.gz/tar.bz2).4.2.1 Compress a file, files, a tar archive.4.1.4 Combining two archive files into one.4.1.3 Adding (appending) files to the end of an archive.4.1.2 Archiving files or directories that start with a particular letter.1 Using tar to archive files and directories.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |