".tar.bz2" and ".tbz" are commonly used extensions for bzip compressed files. "tar.gz" and tgz are common extensions for files compressed with gzip. new/ The extension of the file name does not really matter. In order to compress, use the "z" or "j" option for gzip or bzip respectively. Just a plain archive, that puts multiple files together without any real compression. The above example does not create a compressed archive. The following command creates a tar archive using a directory, adding all files in it and sub directories as well. The tar command can be told to put selected files in an archive or an entire directory. Now that we have learnt how to extract existing tar archives, its time to start creating new ones. rw-rw-r- enlightened/enlightened 0 11:40. Use the above command in combination with the grep command to search the archive. Using the "v" verbose option shall print additional details about each file.įor tar.bz2/bzip files use the "j" option Pipe the output to grep to search a file or less command to browse the list. The following command prints the contents of a gzipped tar archive, $ tar -tz -f If you want to just list out the contents of the tar archive and not extract them, use the "-t" option. List and search contents of the tar archive For example all files with ".txt" extension. Wildcards can be used to extract out a bunch of files matching the given wildcards. More than once file can be specified in the above command like this $ tar -xv -f "./new/cde.txt" "./new/abc.txt" 4. To extract a single file out of an archive just add the file name after the command like this $ tar -xz -f "./new/abc.txt" However first make sure that the destination directory exists, since tar is not going to create the directory for you and will fail if it does not exist. To extract out the files to a specific directory, specify the path using the "-C" option. Extract files to a specific directory or path Use the j option instead of the z option. Those are some of the important options to memoriseįiles with extension bz2 are compressed with the bzip algorithm and tar command can deal with them as well. V - verbose, print the file names as they are extracted one by oneį - Use the following tar archive for the operation Here is a quick explanation of the parameters used - x - Extract files The following command shall extract the files out a tar.gz archive $ tar -xvzf Well, the more common use is to extract tar archives. It is also possible to create uncompressed archives. The "z" option specifies gzip and "j" option specifies bzip. With tar there are 2 compression formats, gzip and bzip. The tar command is available by default on most linux systems and you do not need to install it separately. In this tutorial we shall take a look at simple examples of using the tar command to do daily jobs of creating and extracting archives on linux desktops or servers. tar.bz2 which is a tar archive further compressed using gzip or bzip algorithms respectively.
0 Comments
Leave a Reply. |