AR(1) | General Commands Manual | AR(1) |
ar
— create and
maintain library archives
ar |
-d [-TLsv ]
archive file ... |
ar |
-m [-TLsv ]
archive file ... |
ar |
-m [-abiTLsv ]
position archive file ... |
ar |
-p [-TLsv ]
archive [file ...] |
ar |
-q [-cTLsv ]
archive file ... |
ar |
-r [-cuTLsv ]
archive file ... |
ar |
-r [-abciuTLsv ]
position archive file ... |
ar |
-t [-TLsv ]
archive [file ...] |
ar |
-x [-ouTLsv ]
archive [file ...] |
The ar
utility creates and maintains
groups of files combined into an archive. Once an archive has been created,
new files can be added and existing files can be extracted, deleted, or
replaced.
Files are named in the archive by a single component, i.e., if a file referenced by a path containing a slash (``/'') is archived it will be named by the last component of that path. When matching paths listed on the command line against file names stored in the archive, only the last component of the path will be compared.
All informational and error messages use the path listed on the command line, if any was specified, otherwise the name in the archive is used. If multiple files in the archive have the same name, and paths are listed on the command line to ``select'' archive files for an operation, only the first file with a matching name will be selected.
The normal use of ar
is for the creation
and maintenance of libraries suitable for use with the loader (see
ld(1)) although it is not restricted to this purpose. The
options are as follows:
-a
-r
and -m
. The files are entered or moved
after
the archive member position, which must be
specified.-b
-r
and -m
. The files are entered or moved
before
the archive member position, which must be
specified.-c
-c
option is
specified, ar
creates the archive silently.-d
-i
-b
option.-m
-a
, -b
or
-i
are specified, the files are moved before or
after the position file in the archive. If none of
those options are specified, the files are moved to the end of the
archive.-o
-p
-q
-r
option, when creating a large archive
piece-by-piece, as no checking is done to see if the files already exist
in the archive.-r
-a
, -b
or
-i
is specified.-T
-L
-s
-S
-t
-u
-r
option, files
in the archive will be replaced only if the disk file has a newer
modification time than the file in the archive. When used with the
-x
option, files in the archive will be extracted
only if the archive file has a newer modification time than the file on
disk.-v
-d
,
-m
, -q
or
-x
options, ar
gives a
file-by-file description of the archive modification. This description
consists of three, white-space separated fields: the option letter, a dash
(``-'') and the file name. When used with the -r
option, ar
displays the description as above, but
the initial letter is an ``a'' if the file is added to the archive and an
``r'' if the file replaces a file already in the archive.
When used with the -p
option, the name
of each printed file is written to the standard output before the
contents of the file, preceded by a single newline character, and
followed by two newline characters, enclosed in less-than (``<'') and
greater-than (``>'') characters.
When used with the -t
option,
ar
displays an ``ls -l'' style listing of
information about the members of the archive. This listing consists of
eight, white-space separated fields: the file permissions (see
strmode(3) ), the decimal user and group ID's,
separated by a single slash (``/''), the file size (in bytes), the file
modification time (in the date(1) format ``%b %e %H:%M
%Y''), and the name of the file.
-x
If the file does not exist, it is created; if it does exist,
the owner and group will be unchanged. The file access and modification
times are the time of the extraction (but see the
-o
option). The file permissions will be set to
those of the file when it was entered into the archive; this will fail
if the user is not the owner of the extracted file or the
super-user.
The ar
utility exits 0 on success, and
>0 if an error occurs.
TMPDIR
By default, ar
writes archives that may be
incompatible with historic archives, as the format used for storing archive
members with names longer than fifteen characters has changed. This
implementation of ar
is backward compatible with
previous versions of ar
in that it can read and
write (using the -T
option) historic archives. The
-T
option is provided for compatibility only, and
will be deleted in a future release. See ar(5) for more
information.
The ar
utility is expected to offer a
superset of the IEEE Std 1003.2
(“POSIX.2”) functionality.
July 27, 2005 | Darwin |