source: freewrt/tools/paxmirabilis/src/tar.1@ dbbcad4

freewrt_1_0 freewrt_2_0
Last change on this file since dbbcad4 was dbbcad4, checked in by Thorsten Glaser <tg@…>, 19 years ago

sync with MirCpio: introduce "extract to stdout" option

"schön" wbx@

git-svn-id: svn://www.freewrt.org/trunk/freewrt@207 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 11.1 KB
Line 
1.\" $MirOS: src/bin/pax/tar.1,v 1.7 2006/07/16 16:14:50 tg Exp $
2.\" $OpenBSD: tar.1,v 1.47 2005/05/24 16:33:45 jaredy Exp $
3.\"
4.\" Copyright (c) 1996 SigmaSoft, Th. Lockert
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" $OpenBSD: tar.1,v 1.47 2005/05/24 16:33:45 jaredy Exp $
28.\"
29.Dd February 7, 2001
30.Dt TAR 1
31.Os
32.Sh NAME
33.Nm tar
34.Nd tape archiver
35.Sh SYNOPSIS
36.Nm tar
37.Sm off
38.No { Cm crtux No } Op Cm 014578befHhLmOoPRSpqsvwXZz
39.Sm on
40.Bk -words
41.Op Ar blocking-factor | archive | replstr
42.Op Fl C Ar directory
43.Op Fl I Ar file
44.Op Ar file ...
45.Ek
46.Pp
47.Nm tar
48.No { Ns Fl crtux Ns }
49.Op Fl 014578eHhLmOoPpqvwXZz
50.Op Fl b Ar blocking-factor
51.Op Fl C Ar directory
52.Op Fl f Ar archive
53.Op Fl I Ar file
54.Op Fl M Ar value
55.Op Fl s Ar replstr
56.Op Ar file ...
57.Sh DESCRIPTION
58The
59.Nm
60command creates, adds files to, or extracts files from an
61archive file in
62.Dq tar
63format.
64A tar archive is often stored on a magnetic tape, but can be
65stored equally well on a floppy, CD-ROM, or in a regular disk file.
66.Pp
67In the first (legacy) form, all option flags except for
68.Fl C
69and
70.Fl I
71must be contained within the first argument to
72.Nm
73and must not be prefixed by a hyphen
74.Pq Sq - .
75Option arguments, if any, are processed as subsequent arguments to
76.Nm
77and are processed in the order in which their corresponding option
78flags have been presented on the command line.
79.Pp
80In the second and preferred form, option flags may be given in any order
81and are immediately followed by their corresponding option argument
82values.
83.Pp
84One of the following flags must be present:
85.Bl -tag -width Ds
86.It Fl c
87Create new archive, or overwrite an existing archive,
88adding the specified files to it.
89.It Fl r
90Append the named new files to existing archive.
91Note that this will only work on media on which an end-of-file mark
92can be overwritten.
93.It Fl t
94List contents of archive.
95If any files are named on the
96command line, only those files will be listed.
97The
98.Ar file
99arguments may be specified as glob patterns (see
100.Xr glob 3
101for more information), in which case
102.Nm
103will list all archive members that match each pattern.
104.It Fl u
105Alias for
106.Fl r .
107.It Fl x
108Extract files from archive.
109If any files are named on the
110command line, only those files will be extracted from the
111archive.
112The
113.Ar file
114arguments may be specified as glob patterns (see
115.Xr glob 3
116for more information), in which case
117.Nm
118will extract all archive members that match each pattern.
119.Pp
120If more than one copy of a file exists in the
121archive, later copies will overwrite earlier copies during
122extraction.
123The file mode and modification time are preserved
124if possible.
125The file mode is subject to modification by the
126.Xr umask 2 .
127.El
128.Pp
129In addition to the flags mentioned above, any of the following
130flags may be used:
131.Bl -tag -width Ds
132.It Fl b Ar blocking-factor
133Set blocking factor to use for the archive.
134.Nm
135uses 512-byte blocks.
136The default is 20, the maximum is 126.
137Archives with a blocking factor larger than 63 violate the
138.Tn POSIX
139standard and will not be portable to all systems.
140.It Fl C Ar directory
141This is a positional argument which sets the working directory for the
142following files.
143When extracting, files will be extracted into
144the specified directory; when creating, the specified files will be matched
145from the directory.
146.It Fl e
147Stop after the first error.
148.It Fl f Ar archive
149Filename where the archive is stored.
150Defaults to
151.Pa /dev/rst0 .
152.It Fl H
153Follow symlinks given on the command line only.
154.It Fl h
155Follow symbolic links as if they were normal files
156or directories.
157In extract mode this means that a directory entry in the archive
158will not overwrite an existing symbolic link, but rather what the
159link ultimately points to.
160.It Fl I Ar file
161This is a positional argument which reads the names of files to
162archive or extract from the given file, one per line.
163.It Fl L
164Synonym for the
165.Fl h
166option.
167.It Fl M Ar value
168Configure the archive normaliser.
169.Ar value
170is either a number or a string, optionally prefixed with
171.Dq no-
172to turn the flag off.
173See
174.Xr cpio 1
175for a comprehensive list and compatibility notes.
176.Pp
177.Bl -tag -width xxxxxx -compact
178.It Ar inodes
1790x0001: Serialise inodes, zero device info.
180.It Ar links
1810x0002: Store content of hard links only once.
182.It Ar mtime
1830x0004: Zero out the file modification time.
184.It Ar uidgid
1850x0008: Set owner to 0:0 (root:wheel).
186.El
187.Pp
188This option is only implemented for the cpio, sv4cpio,
189ustar, and sv4crc file format writing routines.
190For the ustar format, the
191.Ar inodes
192and
193.Ar links
194specifiers are ignored.
195.It Fl m
196Do not preserve modification time.
197.It Fl O
198If reading, extract files to standard output.
199.br
200If writing, write old-style (non-POSIX) archives.
201.It Fl o
202Don't write directory information that the older (V7) style
203.Nm
204is unable to decode.
205This implies the
206.Fl O
207flag.
208.It Fl P
209Do not strip leading slashes
210.Pq Sq /
211from pathnames.
212The default is to strip leading slashes.
213.It Fl p
214Preserve user and group ID as well as file mode regardless of
215the current
216.Xr umask 2 .
217The setuid and setgid bits are only preserved if the user is
218the superuser.
219Only meaningful in conjunction with the
220.Fl x
221flag.
222.It Fl q
223Select the first archive member that matches each
224.Ar file
225operand.
226No more than one archive member is matched for each
227.Ar file .
228When members of type directory are matched, the file hierarchy rooted at that
229directory is also matched.
230.It Fl R
231Write SysVR4 CPIO files instead of tar or POSIX ustar files.
232Serialise inode numbers, zero out device information.
233The file content of hard links is stored only once.
234.It Fl S
235Write SysVR4 CPIO files with CRC instead of tar or POSIX ustar files.
236Serialise inode numbers, zero out device information.
237The file content of hard links is stored only once.
238.It Fl s Ar replstr
239Modify the archive member names according to the substitution expression
240.Ar replstr ,
241using the syntax of the
242.Xr ed 1
243utility regular expressions.
244.Ar file
245arguments may be given to restrict the list of archive members to those
246specified.
247.Pp
248The format of these regular expressions is
249.Pp
250.Dl /old/new/[gp]
251.Pp
252As in
253.Xr ed 1 ,
254.Va old
255is a basic regular expression (see
256.Xr re_format 7 )
257and
258.Va new
259can contain an ampersand
260.Pq Ql & ,
261.Ql \e Ns Em n
262(where
263.Em n
264is a digit) back-references,
265or subexpression matching.
266The
267.Va old
268string may also contain newline characters.
269Any non-null character can be used as a delimiter
270.Po
271.Ql /
272is shown here
273.Pc .
274Multiple
275.Fl s
276expressions can be specified.
277The expressions are applied in the order they are specified on the
278command line, terminating with the first successful substitution.
279.Pp
280The optional trailing
281.Cm g
282continues to apply the substitution expression to the pathname substring,
283which starts with the first character following the end of the last successful
284substitution.
285The first unsuccessful substitution stops the operation of the
286.Cm g
287option.
288The optional trailing
289.Cm p
290will cause the final result of a successful substitution to be written to
291standard error in the following format:
292.Pp
293.D1 Em original-pathname No >> Em new-pathname
294.Pp
295File or archive member names that substitute to the empty string
296are not selected and will be skipped.
297.It Fl v
298Verbose operation mode.
299.It Fl w
300Interactively rename files.
301This option causes
302.Nm
303to prompt the user for the filename to use when storing or
304extracting files in an archive.
305.It Fl X
306Do not cross mount points in the file system.
307.It Fl Z
308Compress archive using
309.Xr compress 1 .
310.It Fl z
311Compress archive using
312.Xr gzip 1 .
313.El
314.Pp
315The options
316.Op Fl 014578
317can be used to select one of the compiled-in backup devices,
318.Pa /dev/rstN .
319.Sh ENVIRONMENT
320.Bl -tag -width Fl
321.It Ev TMPDIR
322Path in which to store temporary files.
323.It Ev TAPE
324Default tape device to use instead of
325.Pa /dev/rst0 .
326.El
327.Sh FILES
328.Bl -tag -width "/dev/rst0"
329.It Pa /dev/rst0
330default archive name
331.El
332.Sh EXAMPLES
333Create an archive on the default tape drive, containing the files named
334.Pa bonvole
335and
336.Pa sekve :
337.Pp
338.Dl $ tar c bonvole sekve
339.Pp
340Output a
341.Xr gzip 1
342compressed archive containing the files
343.Pa bonvole
344and
345.Pa sekve
346to a file called
347.Pa foriru.tar.gz :
348.Pp
349.Dl $ tar zcf foriru.tar.gz bonvole sekve
350.Pp
351Verbosely create an archive, called
352.Pa backup.tar.gz ,
353of all files matching the shell
354.Xr glob 3
355function
356.Pa *.c :
357.Pp
358.Dl $ tar zcvf backup.tar.gz *.c
359.Pp
360Verbosely list, but do not extract, all files ending in
361.Pa .jpeg
362from a compressed archive named
363.Pa backup.tar.gz .
364Note that the glob pattern has been quoted to avoid expansion by the shell:
365.Pp
366.Dl $ tar tvzf backup.tar.gz '*.jpeg'
367.Pp
368For more detailed examples, see
369.Xr pax 1 .
370.Sh DIAGNOSTICS
371.Nm
372will exit with one of the following values:
373.Bl -tag -width 2n -offset indent
374.It 0
375All files were processed successfully.
376.It 1
377An error occurred.
378.El
379.Pp
380Whenever
381.Nm
382cannot create a file or a link when extracting an archive or cannot
383find a file while writing an archive, or cannot preserve the user
384ID, group ID, file mode, or access and modification times when the
385.Fl p
386option is specified, a diagnostic message is written to standard
387error and a non-zero exit value will be returned, but processing
388will continue.
389In the case where
390.Nm
391cannot create a link to a file,
392.Nm
393will not create a second copy of the file.
394.Pp
395If the extraction of a file from an archive is prematurely terminated
396by a signal or error,
397.Nm
398may have only partially extracted the file the user wanted.
399Additionally, the file modes of extracted files and directories may
400have incorrect file bits, and the modification and access times may
401be wrong.
402.Pp
403If the creation of an archive is prematurely terminated by a signal
404or error,
405.Nm
406may have only partially created the archive, which may violate the
407specific archive format specification.
408.Sh SEE ALSO
409.Xr cpio 1 ,
410.Xr pax 1
411.Sh HISTORY
412A
413.Nm
414command first appeared in
415.At v7 .
416.Sh AUTHORS
417Keith Muller at the University of California, San Diego.
418.Sh CAVEATS
419The
420.Fl L
421flag is not portable to other versions of
422.Nm
423where it may have a different meaning.
424The
425.Fl R ,
426.Fl S ,
427and
428.Fl M
429options are extensions specific to
430.Mx .
Note: See TracBrowser for help on using the repository browser.