add externs, minor cleanup
[unix-history] / usr / src / usr.bin / ar / ar.1
CommitLineData
bdba1630
KB
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
ca4c99eb 3.\"
bdba1630
KB
4.\" This code is derived from software contributed to Berkeley by
5.\" Hugh Smith at The University of Guelph.
b5dc1377 6.\"
bdba1630
KB
7.\" %sccs.include.redist.man%
8.\"
65fef1d4 9.\" @(#)ar.1 6.8 (Berkeley) %G%
bdba1630
KB
10.\"
11.TH AR 1 ""
12.AT 3
13.SH NAME
14ar \- create and maintain library archives
15.SH SYNOPSIS
16.nf
17.ft B
616b39cf
KB
18ar -d [-sv] archive file ...
19ar -m [-sv] archive file ...
20ar -m [-abisv] position archive file ...
21ar -p [-sv] archive [file ...]
22ar -q [-csv] archive file ...
23ar -r [-cusv] archive file ...
24ar -r [-abciusv] position archive file ...
25ar -t [-sv] archive [file ...]
26ar -x [-ousv] archive [file ...]
bdba1630
KB
27.fi
28.ft R
29.SH DESCRIPTION
ca4c99eb 30The
bdba1630
KB
31.I ar
32utility creates and maintains groups of files combined into an archive.
33Once an archive has been created, new files can be added and existing
34files can be extracted, deleted, or replaced.
35.PP
36Files are named in the archive by a single component, i.e., if a file
37referenced by a path containing a slash (``/'') is archived it will be
38named by the last component of that path.
39When matching paths listed on the command line against file names stored
40in the archive, only the last component of the path will be compared.
65fef1d4
KB
41.PP
42All informational and error messages use the path listed on the command
43archive, not the name entered in the archive unless no name was supplied
44on the command line.
bdba1630
KB
45If multiple files in the archive have the same name, and paths are listed
46on the command line to ``select'' archive files for an operation, only the
47.B first
48file with a matching name will be selected.
49.PP
50The normal use of
51.I ar
52is for the creation and maintenance of libraries suitable for use with
53the loader (see
54.IR ld (1))
55although it is not restricted to this purpose.
56The options are as follows:
57.TP
58\-a
59A positioning modifier used with the options \-r and \-m.
60The files are entered or moved
61.B after
62the archive member
63.IR position ,
64which must be specified.
65.TP
66\-b
67A positioning modifier used with the options \-r and \-m.
68The files are entered or moved
69.B before
70the archive member
71.IR position ,
72which must be specified.
73.TP
74\-c
75Whenever an archive is created, an informational message to that effect
76is written to standard error.
77If the \-c option is specified,
78.I ar
79creates the archive silently.
80.TP
81\-d
82Delete the specified archive files.
83.TP
84\-i
85Identical to the \-b option.
86.TP
87\-m
88Move the specified archive files within the archive.
89If one of the options \-a, \-b or \-i are specified, the files are moved
90before or after the
91.I position
92file in the archive.
93If none of those options are specified, the files are moved
94to the end of the archive.
95.TP
96\-o
97Set the access and modification times of extracted files to the
98modification time of the file when it was entered into the archive.
99This will fail if the user is not the owner of the extracted file
100or the super-user.
101.TP
102\-p
103Write the contents of the specified archive files to the standard output.
104If no files are specified, the contents of all the files in the archive
105are written in the order they appear in the archive.
106.TP
107\-q
108(Quickly) append the specified files to the archive.
109If the archive does not exist a new archive file is created.
110Much faster than the \-r option, when creating a large archive
111piece-by-piece, as no checking is done to see if the files already
112exist in the archive.
113.TP
114\-r
115Replace or add the specified files to the archive.
116If the archive does not exist a new archive file is created.
117Files that replace existing files do not change the order of the files
118within the archive.
119New files are appended to the archive unless one of the options \-a, \-b
120or \-i is specified.
121.TP
616b39cf 122\-s
65fef1d4
KB
123Select and/or name archive members using only the first fifteen characters
124of the archive member or command line file name.
125The historic archive format had sixteen bytes for the name, but some
126historic archiver and loader implementations were unable to handle names
127that used the entire space.
5504c5d3 128This means that file names that are not unique in their first fifteen
616b39cf
KB
129characters can subsequently be confused.
130A warning message is printed to the standard error output if any file
131names are truncated.
132(See
133.IR ar (5)
134for more information.)
135.TP
bdba1630
KB
136\-t
137List the specified files in the order in which they appear in the archive,
138each on a separate line.
139If no files are specified, all files in the archive are listed.
140.TP
141\-u
142Update files.
143When used with the \-r option, files in the archive will be replaced
144only if the disk file has a newer modification time than the file in
145the archive.
146When used with the \-x option, files in the archive will be extracted
147only if the archive file has a newer modification time than the file
148on disk.
149.TP
150\-v
151Provide verbose output.
152When used with the \-d, \-m, \-q or \-x options,
153.I ar
154gives a file-by-file description of the archive modification.
155This description consists of three, white-space separated fields: the
156option letter, a dash (``-'') and the file name.
157When used with the \-r option,
158.I ar
159displays the description as above, but the initial letter is an ``a'' if
160the file is added to the archive and an ``r'' if the file replaces a file
161already in the archive.
162.IP
163When used with the \-p option,
164the name of each printed file is written to the standard output before
165the contents of the file, on a line by itself, enclosed in less-than
166(``<'') and greater-than (``>'') characters.
167.IP
168When used with the \-t option,
169.I ar
170displays an ``ls -l'' style listing of information about the files in
171the archive.
172This listing consists of eight, white-space separated fields:
173the file permissions (see
174.IR strmode (3)),
175the decimal user and group ID's, separated by a single slash (``/''),
176the file size (in bytes), the file modification time (in the
177.IR date (1)
178format ``%b %e %H:%M %Y''), and the name of the file.
179.TP
180\-x
181Extract the specified files into the files named by the command line
182arguments.
183If no files are specified, all the files in the archive are extracted into
184the current directory.
185.IP
186If the file does not exist, it is created; if it does exist, the owner
187and group will be unchanged.
188The file access and modification times are the time of the extraction
189(but see the \-o option).
190The file permissions will be set to those of the file when it was entered
191into the archive; this will fail if the user is not the owner of the
192extracted file or the super-user.
193.PP
b5dc1377 194The
bdba1630
KB
195.I ar
196utility exits 0 on success, and >0 if an error occurs.
197.SH ENVIRONMENT
198.TP
199TMPDIR
200The pathname of the directory to use when creating temporary files.
bdba1630
KB
201.SH FILES
202.TP 14
203/tmp
204default temporary file directory
205.TP 14
206ar.XXXXXX
207temporary file names
65fef1d4
KB
208.SH COMPATIBILITY
209By default,
210.I ar
211writes archives that may be incompatible with historic archives, as
212the format used for storing archive members with names longer than
213fifteen characters has changed.
214This implementation of
215.I ar
216is backward compatible with previous versions of
217.I ar
218in that it can read and write (using the \-s option) historic archives.
219The \-s option is provided for compatibility only, and will be deleted
220in a future release.
221See
222.IR ar (5)
223for more information.
224.SH STANDARDS
225The
226.I ar
227utility is expected to offer a superset of the POSIX 1003.2 functionality.
bdba1630 228.SH "SEE ALSO"
65fef1d4 229ld(1), ranlib(1), ar(5)