Read Contents of Tar Gz Without Extracting
Linux tar command
Updated: 11/06/2021 by Computer Promise
On Unix-like operating systems, the tar control creates, maintains, modifies, and extracts files that are archived in the tar format.
This page covers the GNU/Linux version of tar.
Description
"Tar" stands for tape archive. It is an archiving file format.
tar was originally developed in the early days of Unix for the purpose of backing up files to record-based storage devices. It was later formalized every bit role of the POSIX standard, and today is used to collect, distribute, and archive files, while preserving file system attributes such equally user and group permissions, access and modification dates, and directory structures.
This documentation covers the GNU version of tar, which is included with most modern variants of the Linux operating system.
Syntax
tar [-] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | --test-label | u --update | x --extract --go [options] [pathname ...]
Functioning
The first statement to tar should be a role specification: either one of the letters A, c, d, r, t, u, or x, or one of the long part names. A function letter of the alphabet does non need to exist prefixed with a dash ("-"), and may exist combined with other single-letter options. A long function proper noun must exist prefixed with a double dash ("--"). Some options accept a parameter; with the single-letter of the alphabet form these must be given as separate arguments. With the long form, they may be given by appending "= value" to the selection.
For case, the following commands are all equivalent:
tar --create --file=annal.tar file1 file2
tar -c -f annal.tar file1 file2
tar -cf archive.tar file1 file2
tar cf archive.tar file1 file2
Functions
Specifying 1 of the following functions selects what tar's main mode of performance will be:
| A, --catenate, --concatenate | Suspend tar files to an archive. |
| c, --create | Create a new archive. |
| d, --diff, --compare | Calculate whatsoever differences between the archive and the file organization. |
| --delete | Delete from the archive. (This function doesn't work on magnetic tapes). |
| r, --suspend | Append files to the finish of a tar annal. |
| t, --list | Listing the contents of an archive. |
| --test-label | Test the archive label, and go out. |
| u, --update | Append files, just merely those that are newer than the copy in the archive. |
| x, --extract, --go | Extract files from an annal. |
Other options
The following options specify the way tar operates:
| -[0-7][lmh] | Specifies drive and density. (If you're not sure what this ways, y'all don't need to apply this option.) | |||||||||||||||||||||||||||||||||
| -a, --auto-compress | Use the annal'south suffix to make up one's mind the compression program. For example, if this option is specified, an archive with the extension .tar.gz is always handled as if the --gzip pick had been specified (come across --gzip, beneath). | |||||||||||||||||||||||||||||||||
| --add together-file= file | Add file to the archive. (This choice is especially useful when the name of the file begins with a dash.) | |||||||||||||||||||||||||||||||||
| --anchored | File name patterns must lucifer from the kickoff of a file proper name. | |||||||||||||||||||||||||||||||||
| --no-anchored | File proper name patterns may lucifer after whatever "/" (this is the default for excluding files; see --exclude, beneath). | |||||||||||||||||||||||||||||||||
| --atime-preserve | Preserve access times on archived files, either past restoring the times, or (if the operating organization supports it) non changing them in the first identify. | |||||||||||||||||||||||||||||||||
| --no-auto-compress | Do not automatically determine the compression program using the archive file name suffix. | |||||||||||||||||||||||||||||||||
| -b, --blocking-factor BLOCKS | Utilise BLOCKS x 512 bytes-per-record when treatment the annal. | |||||||||||||||||||||||||||||||||
| -B, --read-total-records | "Re-cake" all input. This pick helps read damaged athenaeum. | |||||||||||||||||||||||||||||||||
| --fill-in[= backup-method | Rather than deleting files from the file system, tar will back them upward using the specified fill-in method backup-method, which may be one of the post-obit:
If not specified, backup-method defaults to the value of environment variable VERSION_CONTROL; if VERSION_CONTROL is undefined, backup-method defaults to existing. | |||||||||||||||||||||||||||||||||
| -C, --directory DIR | Change to directory DIR before performing whatsoever operations. | |||||||||||||||||||||||||||||||||
| --check-device | Check device numbers when creating incremental archives. This is the default behavior. | |||||||||||||||||||||||||||||||||
| --no-cheque-device | Exercise non check device numbers when creating incremental archives. | |||||||||||||||||||||||||||||||||
| --checkpoint[= NUMBER] | Utilise "checkpoints": brandish a progress message every NUMBER records (default ten). | |||||||||||||||||||||||||||||||||
| --checkpoint-action= Action | Execute Action at every checkpoint. ACTION may exist ane of the following:
Using --checkpoint-action without --checkpoint will assume the default checkpoint interval of ten records. | |||||||||||||||||||||||||||||||||
| --delay-directory-restore | Delay setting modification times and permissions of extracted directories until extraction has ended. | |||||||||||||||||||||||||||||||||
| --no-delay-directory-restore | Modification times and permissions of extracted directories are set up when all files from this directory are extracted. This is the default. | |||||||||||||||||||||||||||||||||
| --exclude= Design | Avoid operating on files whose names match file proper noun pattern PATTERN. | |||||||||||||||||||||||||||||||||
| --exclude-backups | Exclude backup and lock files from all operations. | |||||||||||||||||||||||||||||||||
| --exclude-caches | Causes tar to exclude all directories that contain a cache directory tag. A cache directory tag is a brusque file with the name CACHEDIR.TAG and having a standard header specified in http://world wide web.brynosaurus.com/cachedir/spec.html. This option excludes the contents of the directory, but archives the directory itself and the CACHEDIR.TAG file. | |||||||||||||||||||||||||||||||||
| --exclude-caches-all | Omit directories containing a CACHEDIR.TAG file entirely. | |||||||||||||||||||||||||||||||||
| --exclude-caches-under | Exclude everything under directories containing a CACHEDIR.TAG file, including the CACHEDIR.TAG file; but, annal the directory. | |||||||||||||||||||||||||||||||||
| --exclude-tag= FILE | Exclude the contents of any directory containing file FILE, but archive the directory and the file FILE. | |||||||||||||||||||||||||||||||||
| --exclude-tag-all= FILE | Omit directories containing file FILE entirely. | |||||||||||||||||||||||||||||||||
| --exclude-tag-under= FILE | Exclude everything under directories containing file FILE including the file FILE; but, archive the directory. | |||||||||||||||||||||||||||||||||
| --exclude-vcs | Exclude version control subdirectories. This option recognizes the files and directories used by many widely-used VCS systems. The files excluded are:
| |||||||||||||||||||||||||||||||||
| -f, --file= Annal | Apply archive file (or device) Annal. | |||||||||||||||||||||||||||||||||
| -F, --info-script, --new-volume-script= NAME | Run script Proper noun at the end of each record (implies -1000). | |||||||||||||||||||||||||||||||||
| --forcefulness-local | Forcefulness tar to treat the archive file as a local file, even if its name contains a colon. | |||||||||||||||||||||||||||||||||
| --full-fourth dimension | Print the full resolution of all file times. | |||||||||||||||||||||||||||||||||
| -one thousand, --listed-incremental= FILE | During a --create operation, this option specifies that the archive be a new GNU-format incremental backup, using snapshot file FILE to determine which files to backup. With other operations, this pick informs tar that the archive is in incremental format. | |||||||||||||||||||||||||||||||||
| -G, --incremental | Handle former GNU-format incremental backups. | |||||||||||||||||||||||||||||||||
| --grouping= Proper name | Strength Proper name as grouping for added files. | |||||||||||||||||||||||||||||||||
| -h, --dereference | Follow symlinks; annal the files they point to. | |||||||||||||||||||||||||||||||||
| -H, --format= FORMAT | Create archive of the given format, where FORMAT is one of the following:
| |||||||||||||||||||||||||||||||||
| --difficult-dereference | Follow hard links; archive the files they refer to. | |||||||||||||||||||||||||||||||||
| -i, --ignore-zeros | Ignore zeroed blocks in archive. Usually an unabridged block of bytes with a value of nix indicates an end-of-annal; this option helps tar handle a damaged annal, or whatever other oddly-formed archive with blocks of zeros in its contents. | |||||||||||||||||||||||||||||||||
| -I, --utilize-shrink-program= PROG | Use external compression program PROG. Use this pick if you lot are non happy with the compression program associated with the suffix at compile time, or if you have a compression program that GNU tar does not back up. The PROG argument must be a valid control, equally you would type information technology at the command-line prompt, with any additional options as needed. Enclose information technology in quotes if it contains white space. PROG should follow two conventions: Kickoff, when invoked without boosted options, it should read data from standard input, shrink information technology and output it on standard output. Secondly, if invoked with the boosted '-d' pick, it should practice exactly the reverse: read the compressed data from the standard input and produce uncompressed data on the standard output. The latter requirement ways you must not employ the '-d' choice as a role of the PROG command invocation itself. | |||||||||||||||||||||||||||||||||
| --ignore-example | Ignore character case when matching patterns or file names. | |||||||||||||||||||||||||||||||||
| --no-ignore-example | Apply instance-sensitive pattern and file name matching (this is the default). | |||||||||||||||||||||||||||||||||
| --ignore-control-error | Ignore exit codes of subprocesses. | |||||||||||||||||||||||||||||||||
| --no-ignore-command-error | Treat non-zero exit codes of subprocesses every bit an fault. | |||||||||||||||||||||||||||||||||
| --ignore-failed-read | Practise non exit merely considering an unreadable file was encountered. | |||||||||||||||||||||||||||||||||
| --index-file= FILE | Send verbose output to file FILE for afterward utilise. | |||||||||||||||||||||||||||||||||
| -j, --bzip2 | This option tells tar to read or write athenaeum using the bzip2 compressor. | |||||||||||||||||||||||||||||||||
| -J, --xz | Tells tar to read or write archives using the xz compressor. | |||||||||||||||||||||||||||||||||
| -thousand, --keep-old-files | Do non overwrite existing files when extracting files from an archive, and return an error if such files exist. | |||||||||||||||||||||||||||||||||
| -K, --starting-file= Proper noun | This option affects extraction only; tar skips extracting files in the archive until information technology finds one that matches name. | |||||||||||||||||||||||||||||||||
| --proceed-newer-files | Don't supplant existing files that are newer than their archive copies. | |||||||||||||||||||||||||||||||||
| -50, --check-links | Bank check the number of links dumped for each processed file. If this number does not lucifer the full number of difficult links for the file, print a warning message. | |||||||||||||||||||||||||||||||||
| -L, --record-length= size[suf] | Change tape afterwards writing a certain number of bytes. If suf is not specified, SIZE is treated as kilobytes (1024 bytes), which is equivalent to specifying suf as B. suf may be one of the post-obit:
| |||||||||||||||||||||||||||||||||
| --level= n | When using the --listed-incremental selection, force an incremental backup of level n. | |||||||||||||||||||||||||||||||||
| --lzip | Read or write archives through the lzip compressor. | |||||||||||||||||||||||||||||||||
| --lzma | Read or write archives through the lzma compressor. | |||||||||||||||||||||||||||||||||
| --lzop | Read or write archives through the lzop compressor. | |||||||||||||||||||||||||||||||||
| -chiliad, --affect | Sets the data modification fourth dimension of extracted files to the extraction time, rather than the information modification time stored in the archive. In other words, affect all extracted files. | |||||||||||||||||||||||||||||||||
| -M, --multi-volume | Create, list, or extract a multi-book archive. Such athenaeum are cleaved into parts and then that they may fit on media as well small to contain the entire archive. | |||||||||||||||||||||||||||||||||
| --mode= permissions | When calculation files to an annal, tar assigns permissions to the archive members, rather than the permissions from the files. The permissions can exist specified either every bit an octal number or every bit symbolic permissions, as with chmod. | |||||||||||||||||||||||||||||||||
| --mtime= appointment | When calculation files to an archive, tar uses date as the modification time of members when creating archives, instead of their actual modification times. The value of date tin exist either a textual engagement representation or a name of the existing file, starting with "/" or ".", in which case the modification time of that file is used. | |||||||||||||||||||||||||||||||||
| -north, --seek | Assume that the archive media supports seeking to arbitrary locations. Commonly, tar determines automatically whether the annal can exist seeked or not; this option is intended for utilise in cases when such recognition fails. Information technology takes effect merely if the archive is open for reading with "--list" or "--extract" options). | |||||||||||||||||||||||||||||||||
| -N, --newer, --afterwards-date= date | Only store files whose data or status has changed on or after date. If date is a file name, the date of that file is used. | |||||||||||||||||||||||||||||||||
| --newer-mtime= date | Like --subsequently-fourth dimension, merely looks at modification times but. | |||||||||||||||||||||||||||||||||
| --null | When tar uses the '--files-from' choice, this selection instructs tar to expect file names terminated with NUL, then tar can correctly work with file names that contain newlines. | |||||||||||||||||||||||||||||||||
| --no-null | Cancels any previous --null option specified. | |||||||||||||||||||||||||||||||||
| --numeric-owner | Always employ numeric IDs, rather than names, for user/group ownership data. | |||||||||||||||||||||||||||||||||
| -O, --to-stdout | Excerpt files to standard output. | |||||||||||||||||||||||||||||||||
| --occurrence[= number] | This option can be used in conjunction with one of the subcommands "--delete", "--unequal", "--extract" or "--list" when a listing of files is given either on the control-line or via '-T' option. This option instructs tar to process just the numberthursday occurrence of each named file. The number defaults to 1, and so: tar -ten -f archive.tar --occurrence filenamewill excerpt the beginning occurrence of the member "filename" from "archive.tar" and will terminate without scanning to the end of the archive. | |||||||||||||||||||||||||||||||||
| --former-archive, --portability | Same equally "--format=v7". | |||||||||||||||||||||||||||||||||
| --one-file-system | Prevents tar from crossing file organisation boundaries when archiving. Tin can be used with whatsoever write operation. | |||||||||||||||||||||||||||||||||
| --overwrite | Overwrite existing files when extracting. | |||||||||||||||||||||||||||||||||
| --overwrite-dir | Overwrite metadata of existing directories when extracting (this is the default behavior). | |||||||||||||||||||||||||||||||||
| --no-overwrite-dir | Preserve metadata of existing directories when extracting. | |||||||||||||||||||||||||||||||||
| --owner= user | Specifies that tar should use user equally the owner of members when creating archives, instead of the user associated with the source file. The user is a username, or a user's numeric ID, or both equally "name : id". | |||||||||||||||||||||||||||||||||
| -p, --preserve-permissions, --same-permissions | When tar is extracting an annal, it normally subtracts the user's umask from the permissions specified in the annal and uses that number every bit the permissions to create the destination file. Specifying this option instructs tar that it should use the permissions directly from the archive. | |||||||||||||||||||||||||||||||||
| -P, --absolute-names | Don't strip leading "/"s from file names. | |||||||||||||||||||||||||||||||||
| --pax-choice= keyword-list | Enables creation of the annal in POSIX.1-2001 format, where keyword-list is a comma-separated listing of keyword options specific to that format. | |||||||||||||||||||||||||||||||||
| --posix | Same as --format=posix. | |||||||||||||||||||||||||||||||||
| --preserve | This is the aforementioned as specifying both "--preserve-permissions" and "--aforementioned-social club". | |||||||||||||||||||||||||||||||||
| --quote-chars= STRING | When displaying files and other members of an annal, tar treats file names in a special way to avoid ambiguities caused by certain characters that may occur in the file proper name; this is called name quoting. The --quote-chars option volition, additionally, quote whatever characters occurring in String. | |||||||||||||||||||||||||||||||||
| --no-quote-chars= STRING | When name quoting, tar never quotes any of the characters in Cord. | |||||||||||||||||||||||||||||||||
| --quoting-manner= Style | When name quoting, use name quoting fashion Fashion. Valid values of STYLE are: literal, shell, shell-always, c, escape, locale, and clocale. The default quoting style is escape, unless overridden while configuring the package. | |||||||||||||||||||||||||||||||||
| -R, --cake-number | With this option specified, tar prints fault messages for read errors with the block number in the archive file. | |||||||||||||||||||||||||||||||||
| --record-size= siz[suf] | Instructs tar to use size bytes-per-record when accessing the annal. The statement tin can be suffixed with a size suffix, e.g., "--tape-size=10K" for 10 kilobytes. | |||||||||||||||||||||||||||||||||
| --recursion | Recurse into directories (this is the default). | |||||||||||||||||||||||||||||||||
| --no-recursion | Do non recurse into subdirectories when archiving. | |||||||||||||||||||||||||||||||||
| --recursive-unlink | Remove existing directory hierarchies before extracting directories of the same name from the archive. | |||||||||||||||||||||||||||||||||
| --remove-files | Remove files after adding them to an archive. | |||||||||||||||||||||||||||||||||
| --restrict | Disable utilize of some potentially harmful tar options. Currently this selection disables trounce invocation. | |||||||||||||||||||||||||||||||||
| --rmt-control= cmd | In cases where tar uses a remote tape server, this option notifies tar that it should use cmd as the remote record server programme instead of the default, "/usr/libexec/rmt". | |||||||||||||||||||||||||||||||||
| --rsh-command= cmd | In cases where tar uses a remote shell to communicate with non-local devices, this option notifies tar that information technology should use cmd instead of the default, rsh. | |||||||||||||||||||||||||||||||||
| -s, --preserve-guild, --same-order | This pick helps when processing large lists of file names on machines with pocket-size amounts of memory. It is used in conjunction with --compare, --listing or --extract. The --same-order pick tells tar that the list of file names to exist listed or extracted is sorted in the aforementioned order as the files in the archive. This allows a large listing of names to be used, even on a small auto that would not otherwise exist able to hold all the names in memory at the aforementioned time. Such a sorted listing can easily be created by running tar -t on the annal and editing its output. This option is probably never needed on modern computer systems. | |||||||||||||||||||||||||||||||||
| -Southward, --sparse | This option instructs tar to test each file for sparseness before attempting to annal it. If the file is sparse it is treated specially, thus allowing to decrease the corporeality of space used past its image in the annal. This selection is meaningful only when creating or updating archives. It has no event on extraction. | |||||||||||||||||||||||||||||||||
| --same-possessor | Attempt to give extracted files the same ownership as exists in the annal (this is the default for superuser). | |||||||||||||||||||||||||||||||||
| --no-same-owner | Exercise not endeavour to restore ownership when extracting. This is the default behavior for ordinary users, so this pick has an effect only for the superuser. | |||||||||||||||||||||||||||||||||
| --no-same-permissions | Utilise the user'southward umask when extracting permissions from the archive. This is the default behavior for ordinary users. | |||||||||||||||||||||||||||||||||
| --no-seek | Do not attempt to seek to arbitrary locations within an annal. | |||||||||||||||||||||||||||||||||
| --show-defaults | Display tar's default options. This tin can be useful in certain crush scripts. | |||||||||||||||||||||||||||||||||
| --evidence-omitted-dirs | When listing or extracting, list each directory that does not match search criteria. | |||||||||||||||||||||||||||||||||
| --bear witness-transformed-names, --show-stored-names | Brandish file or member names afterwards applying any name transformations. In particular, when used in conjunction with one of the archive creation operations it instructs tar to list the member names stored in the archive, instead of the actual file names. | |||||||||||||||||||||||||||||||||
| --sparse-version= version-number | Specifies the format version to use when archiving sparse files. Implies '--sparse'. | |||||||||||||||||||||||||||||||||
| --strip-components= number | Strip given number of leading components from file names before extraction. For case, if archive "archive.tar" contained a fellow member named "/some/file/name", so running:tar --extract --file annal.tar --strip-components=iiwould excerpt this file to file "name". | |||||||||||||||||||||||||||||||||
| --suffix= suffix | Uses the file proper name suffix suffix when backing upwardly files. If --suffix is non specified, the default backup suffix is the value of the environment variable DEFAULT_BACKUP_SUFFIX, or if that variable is not defined, "~". | |||||||||||||||||||||||||||||||||
| -T, --files-from= file | tar uses the contents of file every bit a list of archive members or files to operate on, in addition to those specified on the command line. | |||||||||||||||||||||||||||||||||
| --to-control= command | During extraction, tar volition pipage extracted files to the standard input of command. | |||||||||||||||||||||||||||||||||
| --totals[= signum] | Display byte totals when processing an annal. If signum is specified, these totals are displayed when tar receives signal number signum. | |||||||||||||||||||||||||||||||||
| --transform, --xform= sed-expr | Supercede file names with sed replacement expression sed-expr. For example,tar cf annal.tar --transform 's,^\./,usr/,'adds to archive.tar files from the current working directory, replacing initial "./" prefix with "usr/". | |||||||||||||||||||||||||||||||||
| -U, --unlink-kickoff | Remove a corresponding file from the file system before extracting it from the archive, rather than overwriting information technology. | |||||||||||||||||||||||||||||||||
| --unquote | Unquote file names read in with -T; this is the default. | |||||||||||||||||||||||||||||||||
| --no-unquote | Exercise non unquote file names read in with -T. | |||||||||||||||||||||||||||||||||
| --utc | Print all file times in UTC (universal time). | |||||||||||||||||||||||||||||||||
| -v, --verbose | Operate verbosely. | |||||||||||||||||||||||||||||||||
| -V, --characterization= name | When creating an annal, write proper name as a proper noun record in the annal. When extracting or listing athenaeum, tar only operates on archives with a characterization matching the pattern specified in proper name. | |||||||||||||||||||||||||||||||||
| --volno-file= file | Used in conjunction with "--multi-volume", tar will keep track of which volume of a multi-volume annal information technology's working on in file file. | |||||||||||||||||||||||||||||||||
| -west, --interactive, --confirmation | Ask for confirmation for every action. | |||||||||||||||||||||||||||||||||
| -W, --verify | Attempt to verify the archive after writing it. | |||||||||||||||||||||||||||||||||
| --alarm= keyword | Control brandish of the warning messages identified by keyword. If keyword starts with the prefix "no-", such letters are suppressed. Otherwise, they are enabled. Multiple "--warning" specifications may exist used. At that place are keywords for diverse alert messages available in tar. The two global keywords are:
| |||||||||||||||||||||||||||||||||
| --wildcards | Utilise wildcards. | |||||||||||||||||||||||||||||||||
| --wildcards-match-slash | When this option is specified, a wildcard like "*" in the blueprint tin can friction match a "/" in the name. Otherwise, "/" is matched only past "/". This is the default when tar is excluding files. | |||||||||||||||||||||||||||||||||
| --no-wildcards-match-slash | "/" cannot be matched by a wildcard, only by "/". | |||||||||||||||||||||||||||||||||
| --no-wildcards | Wildcards are non permitted. File names may simply exist matched verbatim. | |||||||||||||||||||||||||||||||||
| -X, --exclude-from= file | Like --exclude, but excludes files matching the patterns listed in the file file. | |||||||||||||||||||||||||||||||||
| -z, --gzip, --gunzip | This option tells tar to read or write archives through gzip, assuasive tar to direct operate on several kinds of compressed athenaeum transparently. This option should be used, for example, when operating on files with the extension .tar.gz. | |||||||||||||||||||||||||||||||||
| -Z, --compress, --uncompress | tar uses the compress program when operating on files. |
Environment
The post-obit environs variables impact the operation of tar:
| SIMPLE_BACKUP_SUFFIX | File name suffix to employ when bankroll up files, if --suffix is not specified. The default fill-in suffix is "~". |
| TAR_OPTIONS | Any options specified in this variable will be prepended to options specified to tar on the command line. |
| TAPE | The archiving tape or file to use if --file is not specified. If this variable is not defined, and no --file is specified, tar uses standard input and standard output instead. |
Examples
tar -cf archive.tar file1 file2
Create annal archive.tar containing files file1 and file2. Here, the c tells tar you will exist creating an annal; the f tells tar that the next option (hither it's archive.tar) volition be the name of the archive it creates. file1 and file2, the final arguments, are the files to be archived.
tar -tvf annal.tar
List the files in the archive archive.tar verbosely. Here, the t tells tar to list the contents of an archive; v tells tar to operate verbosely; and f indicates that the side by side argument will be the name of the archive file to operate on.
tar -xf archive.tar
Extract the files from annal archive.tar. x tells tar to excerpt files from an archive; f tells tar that the next argument will be the name of the archive to operate on.
tar -xzvf archive.tar.gz
Excerpt the files from gzipped annal archive.tar.gz verbosely. Here, the z tells tar that the archive will be compressed with gzip.
tar -cf archive.tar mydir/
Creates an archive of the directory mydir.
tar -czf archive.tar.gz mydir/
Creates an gzip-compressed archive of the directory mydir.
tar -zxvf myfile.tar.gz
Extract the contents of the myfile.tar.gz into the current directory.
tar -xvf archive.tar documents/piece of work/upkeep.doc
Extract but the file documents/work/budget.doc from the archive archive.tar. Produce verbose output.
tar -xvf annal.tar documents/work/
Excerpt only the directory documents/work/, and any files it contains, from the archive archive.tar. Produce verbose output.
tar -xvf archive.tar --wildcards '*.doc'
Extract only files with the extension .doctor from the archive archive.tar. The --wildcards selection tells tar to interpret wildcards in the name of the files to exist extracted; the file name (*.doc) is enclosed in single-quotes to protect the wildcard (*) from beingness expanded incorrectly by the shell.
tar -rvf annal.tar documents/work/upkeep.doc
Add the file documents/work/budget.dr. to the existing archive annal.tar. The r option is the same as the long option --append.
tar -uvf archive.tar documents/work/upkeep.doc
Add the file documents/piece of work/budget.medico to the annal archive.tar merely if it'south newer than the version already in the archive (or does not yet exist in the annal). Hither, u is the same as the long choice --update.
tar -cf - documents/work/ | wc -c
Estimate the file size of an archive of the directory documents/work, but do not create the file. Here, the archive file is specified as a dash ("-"), which tells tar to transport its archived output to the standard output rather than a file on disk. This output is and then piped to the wc command, which reports how many bytes (-c) were in the input information technology received.
tar -czf DogPhotos.tar.gz --exclude='kitty.jpg' MyPetPhotos
Create DogPhotos.tar.gz of all files contained in the MyPetPhotos without the kitty.jpg photograph.
tar tf promise.tar.gz | grep myfile.txt
Search the hope.tar.gz file for the file myfile.txt and list the full path of the file. The returned results would resemble the line shown below.
computerhopehope/homedir/public_html/data/myfile.txt
tar -zxvf hope.tar.gz computerhopehope/homedir/public_html/data/myfile.txt
In the higher up example, the tar command would excerpt the one file myfile.txt from the hope.tar.gz. The full path to this file was adamant using the instance shown before.
ar — Create, modify, and extract files from archives.
basename — Strip directory information and suffixes from file names.
cd — Change the working directory.
chown — Modify the ownership of files or directories.
cpio — Copy files to or from archives.
dirname — Strip the file proper name from a pathname, leaving only the directory component.
gzip —Create, alter, list the contents of, and extract files from GNU nada athenaeum.
ls — List the contents of a directory or directories.
mt — Control magnetic tapes.
zcat — Impress the uncompressed contents of compressed files.
parsonenterhad1964.blogspot.com
Source: https://www.computerhope.com/unix/utar.htm
0 Response to "Read Contents of Tar Gz Without Extracting"
Post a Comment