386BSD 0.1 development
[unix-history] / usr / src / usr.bin / ar / ar.1
CommitLineData
b85f3be7
WJ
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Hugh Smith at The University of Guelph.
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.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" @(#)ar.1 6.10 (Berkeley) 3/21/91
36.\"
37.TH AR 1 "March 21, 1991"
38.AT 3
39.SH NAME
40ar \- create and maintain library archives
41.SH SYNOPSIS
42.nf
43.ft B
44ar -d [-Tv] archive file ...
45ar -m [-Tv] archive file ...
46ar -m [-abiTv] position archive file ...
47ar -p [-Tv] archive [file ...]
48ar -q [-cTv] archive file ...
49ar -r [-cuTv] archive file ...
50ar -r [-abciuTv] position archive file ...
51ar -t [-Tv] archive [file ...]
52ar -x [-ouTv] archive [file ...]
53.fi
54.ft R
55.SH DESCRIPTION
56The
57.I ar
58utility creates and maintains groups of files combined into an archive.
59Once an archive has been created, new files can be added and existing
60files can be extracted, deleted, or replaced.
61.PP
62Files are named in the archive by a single component, i.e., if a file
63referenced by a path containing a slash (``/'') is archived it will be
64named by the last component of that path.
65When matching paths listed on the command line against file names stored
66in the archive, only the last component of the path will be compared.
67.PP
68All informational and error messages use the path listed on the command
69line, if any was specified, otherwise the name in the archive is used.
70If multiple files in the archive have the same name, and paths are listed
71on the command line to ``select'' archive files for an operation, only the
72.B first
73file with a matching name will be selected.
74.PP
75The normal use of
76.I ar
77is for the creation and maintenance of libraries suitable for use with
78the loader (see
79.IR ld (1))
80although it is not restricted to this purpose.
81The options are as follows:
82.TP
83\-a
84A positioning modifier used with the options \-r and \-m.
85The files are entered or moved
86.B after
87the archive member
88.IR position ,
89which must be specified.
90.TP
91\-b
92A positioning modifier used with the options \-r and \-m.
93The files are entered or moved
94.B before
95the archive member
96.IR position ,
97which must be specified.
98.TP
99\-c
100Whenever an archive is created, an informational message to that effect
101is written to standard error.
102If the \-c option is specified,
103.I ar
104creates the archive silently.
105.TP
106\-d
107Delete the specified archive files.
108.TP
109\-i
110Identical to the \-b option.
111.TP
112\-m
113Move the specified archive files within the archive.
114If one of the options \-a, \-b or \-i are specified, the files are moved
115before or after the
116.I position
117file in the archive.
118If none of those options are specified, the files are moved
119to the end of the archive.
120.TP
121\-o
122Set the access and modification times of extracted files to the
123modification time of the file when it was entered into the archive.
124This will fail if the user is not the owner of the extracted file
125or the super-user.
126.TP
127\-p
128Write the contents of the specified archive files to the standard output.
129If no files are specified, the contents of all the files in the archive
130are written in the order they appear in the archive.
131.TP
132\-q
133(Quickly) append the specified files to the archive.
134If the archive does not exist a new archive file is created.
135Much faster than the \-r option, when creating a large archive
136piece-by-piece, as no checking is done to see if the files already
137exist in the archive.
138.TP
139\-r
140Replace or add the specified files to the archive.
141If the archive does not exist a new archive file is created.
142Files that replace existing files do not change the order of the files
143within the archive.
144New files are appended to the archive unless one of the options \-a, \-b
145or \-i is specified.
146.TP
147\-T
148Select and/or name archive members using only the first fifteen characters
149of the archive member or command line file name.
150The historic archive format had sixteen bytes for the name, but some
151historic archiver and loader implementations were unable to handle names
152that used the entire space.
153This means that file names that are not unique in their first fifteen
154characters can subsequently be confused.
155A warning message is printed to the standard error output if any file
156names are truncated.
157(See
158.IR ar (5)
159for more information.)
160.TP
161\-t
162List the specified files in the order in which they appear in the archive,
163each on a separate line.
164If no files are specified, all files in the archive are listed.
165.TP
166\-u
167Update files.
168When used with the \-r option, files in the archive will be replaced
169only if the disk file has a newer modification time than the file in
170the archive.
171When used with the \-x option, files in the archive will be extracted
172only if the archive file has a newer modification time than the file
173on disk.
174.TP
175\-v
176Provide verbose output.
177When used with the \-d, \-m, \-q or \-x options,
178.I ar
179gives a file-by-file description of the archive modification.
180This description consists of three, white-space separated fields: the
181option letter, a dash (``-'') and the file name.
182When used with the \-r option,
183.I ar
184displays the description as above, but the initial letter is an ``a'' if
185the file is added to the archive and an ``r'' if the file replaces a file
186already in the archive.
187.IP
188When used with the \-p option,
189the name of each printed file is written to the standard output before
190the contents of the file, preceded by a single newline character, and
191followed by two newline characters, enclosed in less-than (``<'') and
192greater-than (``>'') characters.
193.IP
194When used with the \-t option,
195.I ar
196displays an ``ls -l'' style listing of information about the members of
197the archive.
198This listing consists of eight, white-space separated fields:
199the file permissions (see
200.IR strmode (3)),
201the decimal user and group ID's, separated by a single slash (``/''),
202the file size (in bytes), the file modification time (in the
203.IR date (1)
204format ``%b %e %H:%M %Y''), and the name of the file.
205.TP
206\-x
207Extract the specified archive members into the files named by the command
208line arguments.
209If no members are specified, all the members of the archive are extracted into
210the current directory.
211.IP
212If the file does not exist, it is created; if it does exist, the owner
213and group will be unchanged.
214The file access and modification times are the time of the extraction
215(but see the \-o option).
216The file permissions will be set to those of the file when it was entered
217into the archive; this will fail if the user is not the owner of the
218extracted file or the super-user.
219.PP
220The
221.I ar
222utility exits 0 on success, and >0 if an error occurs.
223.SH ENVIRONMENT
224.TP
225TMPDIR
226The pathname of the directory to use when creating temporary files.
227.SH FILES
228.TP 14
229/tmp
230default temporary file directory
231.TP 14
232ar.XXXXXX
233temporary file names
234.SH COMPATIBILITY
235By default,
236.I ar
237writes archives that may be incompatible with historic archives, as
238the format used for storing archive members with names longer than
239fifteen characters has changed.
240This implementation of
241.I ar
242is backward compatible with previous versions of
243.I ar
244in that it can read and write (using the \-T option) historic archives.
245The \-T option is provided for compatibility only, and will be deleted
246in a future release.
247See
248.IR ar (5)
249for more information.
250.SH STANDARDS
251The
252.I ar
253utility is expected to offer a superset of the POSIX 1003.2 functionality.
254.SH "SEE ALSO"
255ld(1), ranlib(1), strmode(3), ar(5)