HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)
a
ar(1) ar(1)
NAME
ar - create and maintain portable archives and libraries
SYNOPSIS
ar [-]key [-][modifier ...] [posname] afile [name ...]
DESCRIPTION
The
ar command maintains groups of files combined into a single archive file. Its main use is to create and
update library files as used by the link editor (see ld(1)). It can be used, however, for any similar purpose.
The magic string and file headers used by
ar consist of printable ASCII characters. If an archive is com-
posed of printable files, the entire archive is printable.
Individual files are inserted without conversion into the archive file. When
ar creates an archive, it
creates headers in a format that is portable across all machines. See ar(4) for a detailed description of the
portable archive format and structure. The archive symbol table (described in ar(4)) is used by the link edi-
tor to search repeatedly and efficiently through libraries of object files. An archive symbol table is created
and maintained by
ar only when the archive contains at least one object file. The archive symbol table is
in a specially named file that is always the first file in the archive. This file is never mentioned or accessi-
ble to the user. Whenever ar is used to create or update the contents of an archive, the symbol table is
rebuilt (unless the z modifier is used). The s modifier described below forces the symbol table to be rebuilt.
One key operation character from the set, drqtpmx, is required and can be optionally preceded by a
hyphen (-). The required key operation character can be specified with one or more modifier characters
from the set
abcfFilsuvzACT
. posname is used with the r and m key operations and the a, b, and i
modifiers to specify a position in the archive. afile is the archive file. Constituent files in the archive file
are specified by name arguments.
The following list describes the key operation characters:
d Delete the named files from the archive file.
r Replace the named files, or add a new file to the archive:
• If the u modifier is used with the operation character r, only those files with modification
dates later than those of the corresponding member files are replaced.
• If an optional positioning character from the set
abi is used, the posname argument must be
present and specifies that new files are to be placed after (a
) or before (b or i) posname.In
the absence of a positioning character, new files are placed at the end.
•
ar creates afile if it does not already exist.
• If no name is specified and:
• the specified archive file does not exist, ar creates an empty archive file containing only
the archive header (see ar(4)).
• the archive contains one or more files whose names match names in the current directory,
each matching archive file is replaced by the corresponding local file without considering
which file may be newer unless the u modifier is also specified.
q Quickly append the named files to the end of the archive file. Positioning characters are invalid.
The operation does not check to determine whether the added members are already in the
archive. ar creates afile if it does not already exist.
t Print a table of contents of the archive file to the standard output. If no names are given, all
files in the archive are described. If names are given, information about only those files appears.
p Print the named files in the archive to the standard output. If no names are specified, the con-
tents of all files are printed in the order that they appear in the archive.
m Move the named files. By default, the files are moved to the end of the archive. If a positioning
character is present, the posname argument must be present and, as in the r operation,
posname specifies where the files are to be moved. Note that, when used with a positioning char-
acter, the files are moved in the same order that they currently appear in the archive, not in the
order specified on the command line. See EXAMPLES.
x Extract the named files. If no names are given, all files in the archive are extracted. In neither
case does x alter entries from the archive file.
Section 1−−20 Hewlett-Packard Company − 1 − HP-UX 11i Version 1: September 2005