change so that the command line file name is used for error/info messages
[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.\"
5504c5d3 9.\" @(#)ar.1 6.7 (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.
41All informational and error messages use the file name as found in the
42archive, not the path listed on the command line.
43If multiple files in the archive have the same name, and paths are listed
44on the command line to ``select'' archive files for an operation, only the
45.B first
46file with a matching name will be selected.
47.PP
48The normal use of
49.I ar
50is for the creation and maintenance of libraries suitable for use with
51the loader (see
52.IR ld (1))
53although it is not restricted to this purpose.
54The options are as follows:
55.TP
56\-a
57A positioning modifier used with the options \-r and \-m.
58The files are entered or moved
59.B after
60the archive member
61.IR position ,
62which must be specified.
63.TP
64\-b
65A positioning modifier used with the options \-r and \-m.
66The files are entered or moved
67.B before
68the archive member
69.IR position ,
70which must be specified.
71.TP
72\-c
73Whenever an archive is created, an informational message to that effect
74is written to standard error.
75If the \-c option is specified,
76.I ar
77creates the archive silently.
78.TP
79\-d
80Delete the specified archive files.
81.TP
82\-i
83Identical to the \-b option.
84.TP
85\-m
86Move the specified archive files within the archive.
87If one of the options \-a, \-b or \-i are specified, the files are moved
88before or after the
89.I position
90file in the archive.
91If none of those options are specified, the files are moved
92to the end of the archive.
93.TP
94\-o
95Set the access and modification times of extracted files to the
96modification time of the file when it was entered into the archive.
97This will fail if the user is not the owner of the extracted file
98or the super-user.
99.TP
100\-p
101Write the contents of the specified archive files to the standard output.
102If no files are specified, the contents of all the files in the archive
103are written in the order they appear in the archive.
104.TP
105\-q
106(Quickly) append the specified files to the archive.
107If the archive does not exist a new archive file is created.
108Much faster than the \-r option, when creating a large archive
109piece-by-piece, as no checking is done to see if the files already
110exist in the archive.
111.TP
112\-r
113Replace or add the specified files to the archive.
114If the archive does not exist a new archive file is created.
115Files that replace existing files do not change the order of the files
116within the archive.
117New files are appended to the archive unless one of the options \-a, \-b
118or \-i is specified.
119.TP
616b39cf 120\-s
5504c5d3
KB
121Truncate file names to fit in the historical archive file format.
122The historic format had sixteen bytes for the name, but historic
123implementations couldn't handle names that used the entire space,
124so this option causes file names longer than fifteen characters to
125be truncated.
126This means that file names that are not unique in their first fifteen
616b39cf
KB
127characters can subsequently be confused.
128A warning message is printed to the standard error output if any file
129names are truncated.
130(See
131.IR ar (5)
132for more information.)
133.TP
bdba1630
KB
134\-t
135List the specified files in the order in which they appear in the archive,
136each on a separate line.
137If no files are specified, all files in the archive are listed.
138.TP
139\-u
140Update files.
141When used with the \-r option, files in the archive will be replaced
142only if the disk file has a newer modification time than the file in
143the archive.
144When used with the \-x option, files in the archive will be extracted
145only if the archive file has a newer modification time than the file
146on disk.
147.TP
148\-v
149Provide verbose output.
150When used with the \-d, \-m, \-q or \-x options,
151.I ar
152gives a file-by-file description of the archive modification.
153This description consists of three, white-space separated fields: the
154option letter, a dash (``-'') and the file name.
155When used with the \-r option,
156.I ar
157displays the description as above, but the initial letter is an ``a'' if
158the file is added to the archive and an ``r'' if the file replaces a file
159already in the archive.
160.IP
161When used with the \-p option,
162the name of each printed file is written to the standard output before
163the contents of the file, on a line by itself, enclosed in less-than
164(``<'') and greater-than (``>'') characters.
165.IP
166When used with the \-t option,
167.I ar
168displays an ``ls -l'' style listing of information about the files in
169the archive.
170This listing consists of eight, white-space separated fields:
171the file permissions (see
172.IR strmode (3)),
173the decimal user and group ID's, separated by a single slash (``/''),
174the file size (in bytes), the file modification time (in the
175.IR date (1)
176format ``%b %e %H:%M %Y''), and the name of the file.
177.TP
178\-x
179Extract the specified files into the files named by the command line
180arguments.
181If no files are specified, all the files in the archive are extracted into
182the current directory.
183.IP
184If the file does not exist, it is created; if it does exist, the owner
185and group will be unchanged.
186The file access and modification times are the time of the extraction
187(but see the \-o option).
188The file permissions will be set to those of the file when it was entered
189into the archive; this will fail if the user is not the owner of the
190extracted file or the super-user.
191.PP
b5dc1377 192The
bdba1630
KB
193.I ar
194utility exits 0 on success, and >0 if an error occurs.
195.SH ENVIRONMENT
196.TP
197TMPDIR
198The pathname of the directory to use when creating temporary files.
199.PP
200.SH FILES
201.TP 14
202/tmp
203default temporary file directory
204.TP 14
205ar.XXXXXX
206temporary file names
207.SH "SEE ALSO"
208date(1), ld(1), ranlib(1), strmode(3), ar(5)