9
TAR (1) BSD General Commands Manual TAR (1) NAME tar — The GNU version of the tar archiving utility SYNOPSIS tar [ -] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | --test-label | u --update | x --extract --get [ options ][ pathname . . . ] DESCRIPTION Tar stores and extracts files from a tape or disk archive. The first argument to tar should be a function; either one of the letters Acdrtux, or one of the long function names. A function letter need not be prefixed with ‘‘-’’, and may be combined with other single-letter options. A long function name must be prefixed with --. Some options take a parameter; with the single- letter form these must be given as separate arguments. With the long form, they may be given by appending =value to the option. FUNCTION LETTERS Main operation mode: -A, --catenate, --concatenate append tar files to an archive -c, --create create a new archive -d, --diff, --compare find differences between archive and file system --delete delete from the archive (not on mag tapes!) -r, --append append files to the end of an archive -t, --list list the contents of an archive --test-label test the archive volume label and exit -u, --update only append files newer than copy in archive -x, --extract, --get extract files from an archive OTHER OPTIONS Operation modifiers: -[0-7][lmh] specify drive and density -a, --auto-compress use archive suffix to determine the compression program Mar 31, 2012 1

tar.pdf

Embed Size (px)

Citation preview

Page 1: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

NAMEtar — The GNU version of the tar archiving utility

SYNOPSIStar [ −] A −−catenate −−concatenate | c −−create | d −−diff −−compare |

−−delete | r −−append | t −−list | −−test−label | u −−update | x−−extract −−get [options] [ pathname ...]

DESCRIPTIONTar stores and extracts files from a tape or disk archive.

The first argument to tar should be a function; either one of the lettersAcdrtux , or one of the long functionnames. Afunction letter need not be prefixed with ‘‘−’ ’, and may be combined with other single-letteroptions. Along function name must be prefixed with−−. Some options take a parameter; with the single-letter form these must be given as separate arguments. With the long form, they may be given by appending=value to the option.

FUNCTION LETTERSMain operation mode:

−A, −−catenate , −−concatenateappend tar files to an archive

−c , −−createcreate a new archive

−d, −−diff , −−comparefind differences between archive and file system

−−deletedelete from the archive (not on mag tapes!)

−r , −−appendappend files to the end of an archive

−t , −−listlist the contents of an archive

−−test−labeltest the archive volume label and exit

−u, −−updateonly append files newer than copy in archive

−x , −−extract , −−getextract files from an archive

OTHER OPTIONSOperation modifiers:

−[0−7][lmh]specify drive and density

−a, −−auto−compressuse archive suffix to determine the compression program

Mar 31, 2012 1

Page 2: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

−−add−file =FILEadd given FILE to the archive (useful if its name starts with a dash)

−−anchoredpatterns match file name start

−−no−anchoredpatterns match after any ‘ /’ (default for exclusion)

−−atime−preservepreserve access times on dumped files, either by restoring the times

−−no−auto−compressdo not use archive suffix to determine the compression program

−b, −−blocking−factor BLOCKSBLOCKS x 512 bytes per record

−B, −−read−full−recordsreblock as we read (for 4.2BSD pipes)

−−backupbackup before removal, choose version CONTROL

−C, −−directory DIRchange to directory DIR

−−check−devicecheck device numbers when creating incremental archives (default)

−−no−check−devicedo not check device numbers when creating incremental archives

−−checkpointdisplay progress messages every NUMBERth record (default 10)

−−checkpoint−action =ACTIONexecute ACTION on each checkpoint

−−delay−directory−restoredelay setting modification times and permissions of extracted

−−no−delay−directory−restorecancel the effect of --delay-directory-restore option

−−exclude =PATTERNexclude files, given as a PATTERN

−−exclude−backupsexclude backup and lock files

−−exclude−cachesexclude contents of directories containing CACHEDIR.TAG,

−−exclude−caches−allexclude directories containing CACHEDIR.TAG

−−exclude−caches−underexclude everything under directories containing CACHEDIR.TAG

Mar 31, 2012 2

Page 3: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

−−exclude−tag =FILEexclude contents of directories containing FILE, except

−−exclude−tag−all =FILEexclude directories containing FILE

−−exclude−tag−under =FILEexclude everything under directories containing FILE

−−exclude−vcsexclude version control system directories

−f , −−file ARCHIVEuse archive file or device ARCHIVE

−F, −−info−script , −−new−volume−script NAMErun script at end of each tape (implies -M)

−−force−localarchive file is local even if it has a colon

−−full−timeprint file time to its full resolution

−g, −−listed−incremental FILEhandle new GNU-format incremental backup

−G, −−incrementalhandle old GNU-format incremental backup

−−group =NAMEforce NAME as group for added files

−h, −−dereferencefollow symlinks; archive and dump the files they point to

−H, −−format FORMATcreate archive of the given formatFORMAT is one of the following:

−−format=gnuGNU tar 1.13.x format

−−format=oldgnuGNU format as per tar <= 1.12

−−format=paxPOSIX 1003.1-2001 (pax) format

−−format=posixsame as pax

−−format=ustarPOSIX 1003.1-1988 (ustar) format

−−format=v7old V7 tar format

−−hard−dereferencefollow hard links; archive and dump the files they refer to

Mar 31, 2012 3

Page 4: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

−i , −−ignore−zerosignore zeroed blocks in archive (means EOF)

−I , −−use−compress−program PROGfilter through PROG (must accept -d)

−−ignore−caseignore case

−−no−ignore−casecase sensitive matching (default)

−−ignore−command−errorignore exit codes of children

−−no−ignore−command−errortreat non-zero exit codes of children as error

−−ignore−failed−readdo not exit with nonzero on unreadable files

−−index−file =FILEsend verbose output to FILE

−j , −−bzip2

−J , −−xz

−k , −−keep−old−filesdon’t replace existing files when extracting

−K, −−starting−file MEMBER-NAMEbegin at member MEMBER-NAME in the archive

−−keep−newer−filesdon’t replace existing files that are newer than their archive copies

−l , −−check−linksprint a message if not all links are dumped

−L, −−tape−length NUMBERchange tape after writing NUMBER x 1024 bytes

−−level =NUMBERdump level for created listed-incremental archive

−−lzip

−−lzma

−−lzop

−m, −−touchdon’t extract file modified time

Mar 31, 2012 4

Page 5: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

−M, −−multi−volumecreate/list/extract multi-volume archive

−−mode=CHANGESforce (symbolic) mode CHANGES for added files

−−mtime =DATE-OR-FILEset mtime for added files from DATE-OR-FILE

−n, −−seekarchive is seekable

−N, −−newer , −−after−date DATE-OR-FILEonly store files newer than DATE-OR-FILE

−−newer−mtime =DATEcompare date and time when data changed only

−−null-T reads null-terminated names, disable -C

−−no−nulldisable the effect of the previous --null option

−−numeric−owneralways use numbers for user/group names

−O, −−to−stdoutextract files to standard output

−−occurrenceprocess only the NUMBERth occurrence of each file in the archive;

−−old−archive , −−portabilitysame as --format=v7

−−one−file−systemstay in local file system when creating archive

−−overwriteoverwrite existing files when extracting

−−overwrite−diroverwrite metadata of existing directories when extracting (default)

−−no−overwrite−dirpreserve metadata of existing directories

−−owner =NAMEforce NAME as owner for added files

−p, −−preserve−permissions , −−same−permissionsextract information about file permissions (default for superuser)

−P, −−absolute−namesdon’t strip leading ‘/’s from file names

−−pax−option =keyword[[:]=value][,keyword[[:]=value]]...control pax keywords

Mar 31, 2012 5

Page 6: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

−−posixsame as --format=posix

−−preservesame as both -p and -s

−−quote−chars =STRINGadditionally quote characters from STRING

−−no−quote−chars =STRINGdisable quoting for characters from STRING

−−quoting−style =STYLEset name quoting style; see below for valid STYLE values

−R, −−block−numbershow block number within archive with each message

−−record−size =NUMBERNUMBER of bytes per record, multiple of 512

−−recursionrecurse into directories (default)

−−no−recursionavoid descending automatically in directories

−−recursive−unlinkempty hierarchies prior to extracting directory

−−remove−filesremove files after adding them to the archive

−−restrictdisable use of some potentially harmful options

−−rmt−command =COMMANDuse given rmt COMMAND instead of rmt

−−rsh−command =COMMANDuse remote COMMAND instead of rsh

−s , −−preserve−order , −−same−ordersort names to extract to match archive

−S, −−sparsehandle sparse files efficiently

−−same−ownertry extracting files with the same ownership as exists in the archive (default for superuser)

−−no−same−ownerextract files as yourself (default for ordinary users)

−−no−same−permissionsapply the user’s umask when extracting permissions from the archive (default for ordinary users)

−−no−seekarchive is not seekable

Mar 31, 2012 6

Page 7: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

−−show−defaultsshow tar defaults

−−show−omitted−dirswhen listing or extracting, list each directory that does not match search criteria

−−show−transformed−names , −−show−stored−namesshow file or archive names after transformation

−−sparse−version =MAJOR[.MINOR]set version of the sparse format to use (implies --sparse)

−−strip−components =NUMBERstrip NUMBER leading components from file names on extraction

−−suffix =STRINGbackup before removal, override usual suffix (’˜’ unless overridden by environment variable SIM-PLE_BACKUP_SUFFIX)

−T, −−files−from FILEget names to extract or create from FILE

−−to−command =COMMANDpipe extracted files to another program

−−totalsprint total bytes after processing the archive;

−−transform , −−xform EXPRESSIONuse sed replace EXPRESSION to transform file names

−U, −−unlink−firstremove each file prior to extracting over it

−−unquoteunquote filenames read with -T (default)

−−no−unquotedo not unquote filenames read with -T

−−utcprint file modification times in UTC

−v , −−verboseverbosely list files processed

−V, −−label TEXTcreate archive with volume name TEXT; at list/extract time, use TEXT as a globbing pattern for vol-ume name

−−volno−file =FILEuse/update the volume number in FILE

−w, −−interactive , −−confirmationask for confirmation for every action

−W, −−verifyattempt to verify the archive after writing it

Mar 31, 2012 7

Page 8: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

−−warning =KEYWORDwarning control

−−wildcardsuse wildcards (default for exclusion)

−−wildcards−match−slashwildcards match ‘/’ (default for exclusion)

−−no−wildcards−match−slashwildcards do not match ‘/’

−−no−wildcardsverbatim string matching

−X, −−exclude−from FILEexclude patterns listed in FILE

−z , −−gzip , −−gunzip −−ungzip

−Z, −−compress , −−uncompress

ENVIRONMENTThe behavior of tar is controlled by the following environment variables, among others:

SIMPLE_BACKUP_SUFFIXBackup prefix to use when extracting, if−−suffix is not specified.The backup suffix defaults to‘˜’ if neither is specified.

TAR_OPTIONSOptions to prepend to those specified on the command line, separated by whitespace.Embeddedbackslashes may be used to escape whitespace or backslashes within an option.

TAPE Device or file to use for the archive if −−file is not specified. If this environment variable isunset, use stdin or stdout instead.

TAR_LONGLINK_100

EXAMPLESCreate archive.tar from files foo and bar.

tar −cf archive.tar foo barList all files in archive.tar verbosely.

tar −tvf archive.tarExtract all files from archive.tar.

tar −xf archive.tar

SEE ALSOtar (5), symlink (7), rmt (8)

HISTORYThetar command appeared in Version 7AT&T UNIX .

BUGSThe GNU folks, in general, abhor man pages, and create info documents instead.Unfortunately, the infodocument describing tar is licensed under the GFDL with invariant cover texts, which makes it impossible to

Mar 31, 2012 8

Page 9: tar.pdf

TAR (1) BSDGeneral Commands Manual TAR (1)

include any text from that document in this man page. Most of the text in this document was automaticallyextracted from the usage text in the source. It may not completely describe all features of the program.

Mar 31, 2012 9