AR(1) COMMAND REFERENCE AR(1)
NAME
ar - archive and library maintainer
SYNOPSIS
ar (dmpqrtx)[abcfilnosuv [ member ] ] afile [ name... ]
DESCRIPTION
Ar maintains groups of files combined into a single archive
file. Its main use is to create and update library files as
used by the loader. It can be used, though, for any similar
purpose.
Key is one character from the set dmpqrtx, optionally
concatenated with one or more of abcfilnosuv (flag). In
cases where the flag is a positioning character, such as a
or b, the member argument is the name of the archive member
which is used as a relative position. The afile argument is
the archive file. The name arguments are constituent files
in the archive file.
If the key given is d, m, q, or r, or if the s flag is
given, the symbol definition table is added or modified by
executing ranlib(1). This can be turned off with the f flag.
It is very important to note that the archive format used on
this system is not the same as on other systems. See the
manual page for ar(5) for information on the format, and see
the second example below for the method of converting
archives to a portable format.
OPTIONS
Keys:
d Delete the named files from the archive file.
m Move the named files to the end of the archive. If a
positioning character is present, then the member
argument must be present, which, as in r, specifies
where the files are to be moved.
p Print the named files in the archive.
q Quickly append the named files to the end of the archive
file. Optional positioning characters are invalid. The
command does not check whether the added members are
already in the archive. The q key is useful only to
avoid quadratic behavior when creating a large archive
piece-by-piece.
r Replace the named files in the archive file. If the
optional character u is used with r, then only those
files with `last-modified' dates later than the archive
Printed 10/17/86 1
AR(1) COMMAND REFERENCE AR(1)
files are replaced. If an optional positioning
character from the set abi is used, then the flag
argument must be present and specifies that new files
are to be placed after (a) or before (b or i) flag.
Otherwise new files are placed at the end.
t Print a table of contents of the archive file. If no
names are given, all files in the archive are tabled.
If names are given, only those files are tabled.
x Extract the named files. If no names are given, all
files in the archive are extracted. In neither case
does x alter the archive file. Normally the `last-
modified' date of each extracted file is the date when
it is extracted. However, if o is used, the `last-
modified' date is reset to the date recorded in the
archive.
Position Names and Flags:
a Position after. The name following the options list is
the name of the archive member after which the given
file is to be positioned. See the descriptions for the
keys m and r, which are the only options for which the a
position name is valid.
b Position before. The name following the options list is
the name of the archive member before which the given
file is to be positioned. See the descriptions for the
keys m and r, which are the only options for which the b
position name is valid.
c Create. Normally ar will create afile when it needs to.
The create flag suppresses the normal message that is
produced when afile is created.
f Prevent symbol definition table creation. This is the
opposite of the s flag. If both f and s are given, the s
is ignored.
i Insert before. This is a synonym for the b position
name.
l Local. Normally ar places its temporary files in the
directory /tmp. This flag causes them to be placed in
the local directory.
n Normal format. This version of ar does not truncate
names longer that 15 characters for insertion into the
archive. In order to use an archive with software which
does not support this archive format, the n flag must be
used to force truncation of names.
Printed 10/17/86 2
AR(1) COMMAND REFERENCE AR(1)
o Preserve original date. This flag is used with the key x
and causes extracted files to have the last-modified
date reset to the date recorded in the archive file.
s Create or update symbol definition table. This flag
causes the command ranlib to be executed with the
archive name as the argument.
u Replace updated files. This flag is used with the r key,
and causes only those files with modification dates
newer than the corresponding member in the archive.
v Verbose. With the verbose flag, ar gives a file-by-file
description of the making of a new archive file from the
old archive and the constituent files. When used with
t, it gives a long listing of all information about the
files. When used with p, it precedes each file with a
name. Otherwise, each file is preceded by the key
letter of the operation done. For example, r - filename
(for replace) and x - filename (for extract).
EXAMPLES
The following invocation of this command,
ar x utils move copy remove
extracts the files move, copy, and remove from the archive
file utils, and places them in the current working
directory.
The following shell script converts a long format archive
file to a normal format archive:
#!/bin/sh -x
#
# Convert long format archive to normal format.
#
if test $# -ne 1
then
echo "$0 : usage : $0 file"
exit 1
fi
Magic=`head -1 $1`
if test "!<arch>" = "$Magic"
then
echo "$0 : The file $1 is already in normal format."
exit 1
Printed 10/17/86 3
AR(1) COMMAND REFERENCE AR(1)
fi
if test "!<ARCH>" != "$Magic"
then
echo "$0 : The file $1 is not an archive file."
exit 1
fi
#
# Build a temporary directory to hold the members.
#
err=1
trap "rm -rf tmp.$$;"' exit $err' 0 1 2 3 15
mkdir tmp.$$
if test $? -ne 0
then
exit 1
fi
cd tmp.$$
ar x ../"$1"
ar crs tmp.a *
mv tmp.a ../"$1"
cd ..
err=0
FILES
/tmp/v* Temporaries
RETURN VALUE
[NO_ERRS] Command completed without error.
[USAGE] Incorrect command line syntax. Execution
terminated.
[NP_WARN] An error warranting a warning message
occurred. Execution continues.
[NP_ERR] An error occurred that was not a system
error. Execution terminated.
[P_WARN] A system error occurred. Execution continues.
See intro(2) for more information on system
errors.
[P_ERR] A system error occurred. Execution
terminated. See intro(2) for more
information on system errors.
CAVEATS
If the same file is mentioned twice in an argument list, it
Printed 10/17/86 4
AR(1) COMMAND REFERENCE AR(1)
may be put in the archive twice.
The last-modified date of a file will not be altered by the
o option if the user is not the owner of the extracted file
or is not the superuser.
The s flag causes ranlib to be executed using the user's
execution path. In addition, ranlib executes ar using the
user's execution path.
SEE ALSO
cpio(1), file(1), ld(1), make(1), nm(1), ranlib(1),
fgetarhdr(3c), getarhdr(3c), ar(5).
Printed 10/17/86 5
%%index%%
na:72,71;
sy:143,269;
de:412,1446;
op:1858,1035;3037,2734;5915,1205;
ex:7120,824;8088,554;
fi:8642,89;
rv:8731,792;
ca:9523,115;9782,474;
se:10256,292;
%%index%%000000000185