for assistance with all your shell programming needs.
ar - archive and library maintainer
ar [mrxtdpqhw] [uvcbailosz] [posname] archive file1 ... fileN
The archiver (ar) maintains groups of files as a single archive file. Gen-
erally, you use this utility to create and update library files that the
link editor uses; however, you can use the archiver for any similar pur-
In the text, option refers to a character (from the set mrxtdpqhw) that you
can concatenate with one or more of uvcbailosz . A suboption refers to
options (from the set uvcbailosz) that you can only use with other flags.
The ar(1) archiver supports file names up to the operating system limit.
The following list describes the flags:
m Moves the specified files to the end of the archive. If you specify a
positioning character, you must also specify the posname (as in flag r)
to tell the archiver where to move the files.
r Replaces the specified files in the archive file. If you use the
suboption u with r, the archiver only replaces those files that have
`last-modified' dates later than the archive files. If you use a posi-
tioning character (from the set abi) you must specify the posname argu-
ment to tell the archiver to put the new files after (a) or before (b
or i). Otherwise, the archiver puts new files at the end of the
R Replicates the entire archive, transferring each file in the archive to
the replica in uncompressed form. If the Z flag is also specified,
each file in the archive is transferred to the replica in compressed
x Extracts the specified files from the archive. If you do not specify
any file names, the archiver extracts all files. When it extracts
files, the archiver does not change any file. Normally, the `last-
modified' date for each extracted file shows the date when someone
extracted it; however, when you use o, the archiver resets the `last-
modified' date to the date recorded in the archive.
t Prints a table of contents for the files in the archive file. If you
do not specify any file names, the archiver builds a table of contents
for all files. If you specify file names, the archiver builds a table
of contents only for those files.
d Deletes the specified files from the archive file.
p Prints the specified files from the archive.
q Appends the specified files to the end of the archive file. The
archiver does not accept suboption positioning characters with the q
flag. It also does not check whether the files you want to add already
exist in the archive. Use the q flag only to avoid quadratic behavior
when you create a large archive piece by piece.
h Sets the file modification times in the member headers of the named
files to the current date and time. If you do not specify any
filenames, ar sets the time stamps of all member headers.
w Displays the archive symbol table. Each symbol is listed with the name
of the archive member which defines the symbol.
Z Compresses each file as it is added to the archive.
The following list describes the suboptions:
a Specifies that the file goes after the existing file (posname). Use
this suboption with the m or r flag.
b Specifies that the file goes before the existing file (posname). Use
this suboption with the m or r flags.
c Suppresses the normal message that the archiver prints when it creates
the specified archive file. Normally, the archiver creates the speci-
fied archiver file when it needs to. The c flag is a suboption of the r
and q flags.
i Specifies that the file goes before the existing file (posname). Use
this suboption with the m or r flags.
l Places temporary files in the local directory. If the l flag is not
used then the value of the environment symbol, TMPDIR, is used as the
directory for temporary files. If TMPDIR is not defined or if the
directory it references is not writable then /tmp is used.
o Forces a newly created file to have the `last modified' date that it
had before it was extracted from the archive. Use this suboption with
the x flag.
s Makes a symbol definition (symdef file) as the first file of an
archive. This file contains a hash table of ranlib structures and a
corresponding string table. If you change the archive contents, the
symdef file becomes obsolete because archive file symbols change. The
ar command builds the symbol table by default.
u Prevents the archiver from replacing an existing file unless the
replacement is newer than the existing file. This suboption uses the
UNIX system `last modified' date for this comparison. Use this subop-
tion with the r option.
v Gives a verbose file-by-file description as the archiver makes a new
archive file from an old archive and its constituent files. When you
use this suboption with the t flag, the archiver lists all information
about the files in the archive, indicating that a file has been
compressed by placing a "Z" in the column that precedes the filename.
When you use this option with p, the archiver precedes each file with a
z Suppresses symbol table building.
If you specify the same file twice in an argument list, it can appear twice
in the archive file.
The o suboption does not change the `last-modified' date of a file unless
you own the extracted file or you are the super-user.
The s suboption is not operative as ar will always build the hash table by
default unless the z suboption is specified.
lorder(1), ld(1), ar(4)