Полезная информация

UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: talkChapter 2
UNIX Commands
Next: Reference: tbl
 

tar

tar [options] [files]

Copy files to or restore files from tape. If any files are directories, tar acts on the entire subtree. Options need not be preceded by -. Note that options are supplied as one group, with any arguments placed afterward in corresponding order.

Function options (choose one)

c

Create a new tape.

r

Append files to tape.

t

Print the names of files if they are stored on the tape (if files not specified, print names of all files).

u

Add files if not on tape or if modified.

x

Extract files from tape (if files not specified, extract all files).

Options

b n

Use blocking factor n (default is 1; maximum is 20).

f arch

Store files in or extract files from archive arch; arch is usually a device name (default is /dev/mt0). If arch is -, standard input or output is used as appropriate (e.g., when piping a tar archive to a remote host).

l

Print error messages about links it can't find.

L

Follow symbolic links.

m

Do not restore file modification times; update them to the time of extraction.

o

Change ownership of extracted files to that of user running program.

v

Print function letter (x for extraction or a for archive) and name of files.

w

Wait for user confirmation (y).

n[c]

Select tape drive n and use speed c. n is 0-7 (default is 0); c is l (low) h (high) m (medium, the default). Used to modify arch.

Examples

Create an archive of /bin and /usr/bin (c), show the command working (v), and store on the tape in /dev/rmt0:

tar cvf /dev/rmt0 /bin /usr/bin

List the tape's contents in a format like ls -l:

tar tvf /dev/rmt0

Extract the /bin directory:

tar xvf /dev/rmt0 /bin

Create an archive of the current directory, and store it in a file backup.tar on the system.

tar cvf - `find . -print` > backup.tar

(The - tells tar to store the directory on standard output, which is then redirected.)


Previous: Reference: talkUNIX in a Nutshell: System V EditionNext: Reference: tbl
Reference: talkBook IndexReference: tbl

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System