Manuál NetBSD

TAR(1) NetBSD General Commands Manual TAR(1)

NAME

tar — tape archiver

SYNOPSIS

tar [

- ]{crtux}[−befhjklmopqvwzHOPSXZ014578] [archive] [blocksize] [−C directory] [−T file] [−s replstr] [file ...]

DESCRIPTION

The tar command creates, adds files to, or extracts files from an archive file in ‘‘tar’’ format. A tar archive is often stored on a magnetic tape, but can be stored equally well on a floppy, CD-ROM, or in a regular disk file.

One of the following flags must be present:

−c, −-create

Create new archive, or overwrite an existing archive, adding the specified files to it.

−r, −-append

Append the named new files to existing archive. Note that this will only work on media on which an end-of-file mark can be overwritten.

−t, −-list

List contents of archive. If any files are named on the command line, only those files will be listed.

−u, −-update

Alias for −r.

−x, −-extract, −-get

Extract files from archive. If any files are named on the command line, only those files will be extracted from the archive. If more than one copy of a file exists in the archive, later copies will overwrite earlier copies during extraction. The file mode and modification time are preserved if possible. The file mode is subject to modification by the umask(2).

In addition to the flags mentioned above, any of the following flags may be used:

−b blocking factor, −-block-size blocking factor

Set blocking factor to use for the archive. tar uses 512 byte blocks. The default is 20, the maximum is 126. Archives with a blocking factor larger 63 violate the POSIX standard and will not be portable to all systems.

−e

Stop after first error.

−f archive, −-file archive

Filename where the archive is stored. Defaults to /dev/rst0. If the archive is of the form: [[user@]host:]file then the archive will be processed using rmt(8).

−h, −-dereference

Follow symbolic links as if they were normal files or directories.

−j, −-bzip2, −-bunzip2

Use bzip2(1) for compression of the archive. This option is a GNU extension.

−k, −-keep-old-files

Keep existing files; don’t overwrite them from archive.

−l, −-one-file-system

Do not cross filesystems.

−m, −-modification-time

Do not preserve modification time.

−O

When creating and appending to an archive, write old-style (non-POSIX) archives. When extracting from an archive, extract to standard output.

−o, −-portability, −-old-archive

Don’t write directory information that the older (V7) style tar is unable to decode. This implies the −O flag.

−p, −-preserve-permissions, −-preserve

Preserve user and group ID as well as file mode regardless of the current umask(2). The setuid and setgid bits are only preserved if the user is the superuser. Only meaningful in conjunction with the −x flag.

−q, −-fast-read

Select the first archive member that matches each pattern operand. No more than one archive member is matched for each pattern. When members of type directory are matched, the file hierarchy rooted at that directory is also matched.

−S, −-sparse

This flag has no effect as tar always generates sparse files.

−s replstr

Modify the file or archive member names specified by the pattern or file operands according to the substitution expression replstr, using the syntax of the ed(1) utility regular expressions. The format of these regular expressions are:

/old/new/[gp]

As in ed(1), old is a basic regular expression and new can contain an ampersand (&), \n (where n is a digit) back-references, or subexpression matching. The old string may also contain 〈newline〉 characters. Any non-null character can be used as a delimiter (/ is shown here). Multiple −s expressions can be specified. The expressions are applied in the order they are specified on the command line, terminating with the first successful substitution. The optional trailing g continues to apply the substitution expression to the pathname substring which starts with the first character following the end of the last successful substitution. The first unsuccessful substitution stops the operation of the g option. The optional trailing p will cause the final result of a successful substitution to be written to standard error in the following format:

<original pathname> >> <new pathname>

File or archive member names that substitute to the empty string are not selected and will be skipped.

−v

Verbose operation mode.

−w, −-interactive, −-confirmation

Interactively rename files. This option causes tar to prompt the user for the filename to use when storing or extracting files in an archive.

−z, −-gzip, −-gunzip

Compress archive using gzip.

−B, −-read-full-blocks

Reassemble small reads into full blocks (For reading from 4.2BSD pipes).

−C directory, −-directory directory

This is a positional argument which sets the working directory for the following files. When extracting, files will be extracted into the specified directory; when creating, the specified files will be matched from the directory. This argument and its parameter may also appear in a file list specified by −T.

−H

Follow symlinks given on command line only.

−P, −-absolute-paths

Do not strip leading slashes (‘/’) from pathnames. The default is to strip leading slashes.

−T file, −-files-from file

Read the names of files to archive or extract from the given file, one per line. A line may also specify the positional argument ‘‘−C directory’’.

−X file, −-exclude-from file

Exclude files listed in the given file.

−Z, −-compress, −-uncompress

Compress archive using compress.

−-strict

Do not enable GNU tar extensions such as long filenames and long link names.

−-atime-preserve

Preserve file access times.

−-chroot

chroot() to the current directory before extracting files. Use with −x and −h to make absolute symlinks relative to the current directory.

−-unlink

Ignored, only accepted for compatibility with other tar implementations. tar always unlinks files before creating them.

−-use-compress-program program

Use the named program as the program to decompress the input.

−-force-local

Do not interpret filenames that contain a ‘:’ as remote files.

−-insecure

Normally tar ignores filenames that contain ‘..’ as a path component. With this option, files that contain ‘..’ can be processed.

−-no-recursion

Cause files of type directory being copied or archived, or archive members of type directory being extracted, to match only the directory file or archive member and not the file hierarchy rooted at the directory.

The options [−014578] can be used to select one of the compiled-in backup devices, /dev/rstN.

FILES
/dev/rst0

default archive name

DIAGNOSTICS

tar will exit with one of the following values:

0

All files were processed successfully.

1

An error occurred.

Whenever tar cannot create a file or a link when extracting an archive or cannot find a file while writing an archive, or cannot preserve the user ID, group ID, file mode, or access and modification times when the −p option is specified, a diagnostic message is written to standard error and a non-zero exit value will be returned, but processing will continue. In the case where tar cannot create a link to a file, tar will not create a second copy of the file.

If the extraction of a file from an archive is prematurely terminated by a signal or error, tar may have only partially extracted the file the user wanted. Additionally, the file modes of extracted files and directories may have incorrect file bits, and the modification and access times may be wrong.

If the creation of an archive is prematurely terminated by a signal or error, tar may have only partially created the archive which may violate the specific archive format specification.

SEE ALSO

cpio(1), pax(1)

HISTORY

A tar command first appeared in Version 7 AT&T UNIX.

AUTHORS

Keith Muller at the University of California, San Diego.

NetBSD 4.0 May 7, 2005 NetBSD 4.0

© Copyright 2006 NetBSD.sk. Ďakujem za mnoho KeNNymu, xyzZovi a Furbymu. Design by Dewden Services.