The ar utility shall conform to the Base Definitions volume of
POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines, except for
Guideline 9.
The following options shall be supported:
-a
Position new files in the archive after the file named
by the posname operand.
-b
Position new files in the archive before the file named
by the posname operand.
-c
Suppress the diagnostic message that is written to
standard error by default when the archive archive is
created.
-C
Prevent extracted files from replacing like-named files
in the file system. This option is useful when -T
is
also used, to prevent truncated filenames from
replacing files with the same prefix.
-d
Delete one or more files from archive.
-i
Position new files in the archive before the file in
the archive named by the posname operand (equivalent to
-b
).
-m
Move the named files in the archive. The -a
, -b
, or -i
options with the posname operand indicate the position;
otherwise, move the names files in the archive to the
end of the archive.
-p
Write the contents of the files in the archive named by
file operands from archive to the standard output. If
no file operands are specified, the contents of all
files in the archive shall be written in the order of
the archive.
-q
Append the named files to the end of the archive. In
this case ar does not check whether the added files are
already in the archive. This is useful to bypass the
searching otherwise done when creating a large archive
piece by piece.
-r
Replace or add files to archive. If the archive named
by archive does not exist, a new archive shall be
created and a diagnostic message shall be written to
standard error (unless the -c
option is specified). If
no files are specified and the archive exists, the
results are undefined. Files that replace existing
files in the archive shall not change the order of the
archive. Files that do not replace existing files in
the archive shall be appended to the archive unless a
-a
, -b
, or -i
option specifies another position.
-s
Force the regeneration of the archive symbol table even
if ar is not invoked with an option that modifies the
archive contents. This option is useful to restore the
archive symbol table after it has been stripped; see
strip.
-t
Write a table of contents of archive to the standard
output. Only the files specified by the file operands
shall be included in the written list. If no file
operands are specified, all files in archive shall be
included in the order of the archive.
-T
Allow filename truncation of extracted files whose
archive names are longer than the file system can
support. By default, extracting a file with a name that
is too long shall be an error; a diagnostic message
shall be written and the file shall not be extracted.
-u
Update older files in the archive. When used with the
-r
option, files in the archive shall be replaced only
if the corresponding file has a modification time that
is at least as new as the modification time of the file
in the archive.
-v
Give verbose output. When used with the option
characters -d
, -r
, or -x
, write a detailed file-by-file
description of the archive creation and maintenance
activity, as described in the STDOUT section.
When used with -p
, write the name of the file in the
archive to the standard output before writing the file
in the archive itself to the standard output, as
described in the STDOUT section.
When used with -t
, include a long listing of
information about the files in the archive, as
described in the STDOUT section.
-x
Extract the files in the archive named by the file
operands from archive. The contents of the archive
shall not be changed. If no file operands are given,
all files in the archive shall be extracted. The
modification time of each file extracted shall be set
to the time the file is extracted from the archive.