1ar(1) User Commands ar(1)
2
3
4
6 ar - maintain portable archive or library
7
9 /usr/bin/ar -d [-Vv] archive file...
10
11
12 /usr/bin/ar -m [-abiVv] [posname] archive file...
13
14
15 /usr/bin/ar -p [-sVv] archive [file]...
16
17
18 /usr/bin/ar -q [-cVv] archive file...
19
20
21 /usr/bin/ar -r [-abciuVv] [posname] archive file...
22
23
24 /usr/bin/ar -t [-sVv] archive [file]...
25
26
27 /usr/bin/ar -x [-CsTVv] archive [file]...
28
29
30 /usr/xpg4/bin/ar -d [-Vv] archive file...
31
32
33 /usr/xpg4/bin/ar -m [-abiVv] [posname] archive file...
34
35
36 /usr/xpg4/bin/ar -p [-sVv] archive [file]...
37
38
39 /usr/xpg4/bin/ar -q [-cVv] archive file...
40
41
42 /usr/xpg4/bin/ar -r [-abciuVv] [posname] archive file...
43
44
45 /usr/xpg4/bin/ar -t [-sVv] archive [file]...
46
47
48 /usr/xpg4/bin/ar -x [-CsTVv] archive [file]...
49
50
52 The ar utility maintains groups of files combined into a single archive
53 file. Its main use is to create and update library files. However, it
54 can be used for any similar purpose. The magic string and the file
55 headers used by ar consist of printable ASCII characters. If an archive
56 is composed of printable files, the entire archive is printable.
57
58
59 When ar creates an archive, it creates headers in a format that is por‐
60 table across all machines. The portable archive format and structure
61 are described in detail in ar.h(3HEAD). The archive symbol table
62 described there is used by the link editor ld(1) to effect multiple
63 passes over libraries of object files in an efficient manner. An ar‐
64 chive symbol table is only created and maintained by ar when there is
65 at least one object file in the archive. The archive symbol table is in
66 a specially named file that is always the first file in the archive.
67 This file is never mentioned or accessible to the user. Whenever the ar
68 command is used to create or update the contents of such an archive,
69 the symbol table is rebuilt. The -s option described below forces the
70 symbol table to be rebuilt.
71
73 The following options are supported:
74
75 -a Positions new files in archive after the file named by the pos‐
76 name operand.
77
78
79 -b Positions new files in archive before the file named by the pos‐
80 name operand.
81
82
83 -c Suppresses the diagnostic message that is written to standard
84 error by default when archive is created.
85
86
87 -C Prevents extracted files from replacing like-named files in the
88 file system. This option is useful when -T is also used to pre‐
89 vent truncated file names from replacing files with the same pre‐
90 fix.
91
92
93 -d Deletes one or more files from archive.
94
95
96 -i Positions new files in archive before the file named by the pos‐
97 name operand. This option is quivalent to -b.
98
99
100 -m Moves files. If -a, -b, or -i with the posname operand are speci‐
101 fied, the -m option moves files to the new position. Otherwise,
102 -m moves files to the end of archive.
103
104
105 -p Prints the contents of files in archive to standard output. If no
106 files are specified, the contents of all files in archive are
107 written in the order of the archive.
108
109
110 -q Quickly appends files to the end of archive. Positioning options
111 -a, -b, and -i are invalid. The command does not check whether
112 the added files are already in archive. This option is useful to
113 avoid quadratic behavior when creating a large archive piece-by-
114 piece.
115
116
117 -r Replaces or adds files in archive. If archive does not exist, a
118 new archive file is created and a diagnostic message is written
119 to standard error, unless the -c option is specified. If no files
120 are specified and the archive exists, the results are undefined.
121 Files that replace existing files do not change the order of the
122 archive. If the -u option is used with the -r option, only those
123 files with dates of modification later than the archive files are
124 replaced. If the -a, -b, or -i option is used, the posname argu‐
125 ment must be present and specifies that new files are to be
126 placed after (-a) or before (-b or -i) posname. Otherwise, the
127 new files are placed at the end.
128
129
130 -s Forces the regeneration of the archive symbol table even if ar is
131 not invoked with an option that will modify the archive contents.
132 This command is useful to restore the archive symbol table after
133 the strip(1) command has been used on the archive.
134
135
136 -t Prints a table of contents of archive. The files specified by the
137 file operands are included in the written list. If no file oper‐
138 ands are specified, all files in archive are included in the
139 order of the archive.
140
141
142 -T Allows file name truncation of extracted files whose archive
143 names are longer than the file system can support. By default,
144 extracting a file with a name that is too long is an error. In
145 that case, a diagnostic message is written and the file is not
146 extracted.
147
148
149 -u Updates older files. When used with the -r option, files within
150 archive are replaced only if the corresponding file has a modifi‐
151 cation time that is at least as new as the modification time of
152 the file within archive.
153
154
155 -v Gives verbose output. When used with options -d, -r, or -x, the
156 -v option writes a detailed file-by-file description of the ar‐
157 chive creation and the constituent files, and maintenance activ‐
158 ity. When used with -p, -v writes the name of the file to the
159 standard output before writing the file itself to the standard
160 output. When used with -t, -v includes a long listing of informa‐
161 tion about the files within the archive. When used with -x, -v
162 prints the filename preceding each extraction. When writing to an
163 archive, -v writes a message to the standard error.
164
165
166 -V Prints its version number on standard error.
167
168
169 /usr/xpg4/bin/ar
170 The following options are supported for /usr/xpg4/bin/ar:
171
172 -v Same as the /usr/bin/ar version, except when writing to an ar‐
173 chive, no message is written to the standard error.
174
175
176 -x Extracts the files named by the file operands from archive. The
177 contents of archive are not changed. If no file operands are
178 given, all files in archive are extracted. If the file name of a
179 file extracted from archive is longer than that supported in the
180 directory to which it is being extracted, the results are unde‐
181 fined. The modification time of each file extracted is set to the
182 time file is extracted from archive.
183
184
186 The following operands are supported:
187
188 archive A path name of the archive file.
189
190
191 file A path name. Only the last component is used when comparing
192 against the names of files in the archive. If two or more
193 file operands have the same last path name component (see
194 basename(1)), the results are unspecified. The implementa‐
195 tion's archive format will not truncate valid file names of
196 files added to or replaced in the archive.
197
198
199 posname The name of a file in the archive file, used for relative
200 positioning. See options -m and -r.
201
202
204 See environ(5) for descriptions of the following environment variables
205 that affect the execution of ar: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
206 LC_TIME, and NLSPATH.
207
208 TMPDIR Determine the pathname that overrides the default directory
209 for temporary files, if any.
210
211
212 TZ Determine the timezone used to calculate date and time
213 strings written by ar -tv. If TZ is unset or null, an unspec‐
214 ified default timezone is used.
215
216
218 The following exit values are returned:
219
220 0 Successful completion.
221
222
223 >0 An error occurred.
224
225
227 See attributes(5) for descriptions of the following attributes:
228
229 /usr/bin/ar
230 ┌─────────────────────────────┬─────────────────────────────┐
231 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
232 ├─────────────────────────────┼─────────────────────────────┤
233 │Availability │SUNWbtool │
234 ├─────────────────────────────┼─────────────────────────────┤
235 │Interface Stability │Committed │
236 └─────────────────────────────┴─────────────────────────────┘
237
238 /usr/xpg4/bin/ar
239 ┌─────────────────────────────┬─────────────────────────────┐
240 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
241 ├─────────────────────────────┼─────────────────────────────┤
242 │Availability │SUNWxcu4 │
243 ├─────────────────────────────┼─────────────────────────────┤
244 │Interface Stability │Committed │
245 ├─────────────────────────────┼─────────────────────────────┤
246 │Standard │See standards(5). │
247 └─────────────────────────────┴─────────────────────────────┘
248
250 basename(1), cpio(1), ld(1), lorder(1), strip(1), tar(1), ar.h(3HEAD),
251 a.out(4), attributes(5), environ(5), standards(5)
252
254 If the same file is mentioned twice in an argument list, it may be put
255 in the archive twice.
256
257
258 By convention, archives are suffixed with ".a".
259
260
261 When inserting ELF objects into an archive file, ar might add "0fR"
262 characters to pad these objects to an 8-byte boundary. Such padding
263 improves the efficiency with which ld(1) can access the archive. Only
264 ELF object files are padded in this way. Other archive members are not
265 altered. When an object with such padding is extracted from an archive,
266 the padding is not included in the resulting output.
267
268
269
270SunOS 5.11 24 Aug 2009 ar(1)