[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    ar(1) manual page Table of Contents

Name

ar - maintain portable archive or library

Synopsis

/usr/ccs/bin/ar -d [ -Vv ] archive file...
/usr/ccs/bin/ar -m [ -abiVv ] [ posname ] archive file...
/usr/ccs/bin/ar -p [ -sVv ] archive [file...]
/usr/ccs/bin/ar -q [ -cVv ] archive file...
/usr/ccs/bin/ar -r [ -abciuVv ] [ posname ] archive file...
/usr/ccs/bin/ar -t [ -sVv ] archive [file...]
/usr/ccs/bin/ar -x [ -CsTVv ] archive [file...]

/usr/xpg4/bin/ar -d [ -Vv ] archive file...
/usr/xpg4/bin/ar -m [ -abiVv ] [ posname ] archive file...
/usr/xpg4/bin/ar -p [ -sVv ] archive [file...]
/usr/xpg4/bin/ar -q [ -cVv ] archive file...
/usr/xpg4/bin/ar -r [ -abciuVv ] [ posname ] archive file...
/usr/xpg4/bin/ar -t [ -sVv ] archive [file...]
/usr/xpg4/bin/ar -x [ -CsTVv ] archive [file...]

Availability

/usr/bin/ar

SUNWbtool

/usr/xpg4/bin/ar

SUNWxcu4

Description

The ar command maintains groups of files combined into a single archive file. Its main use is to create and update library files. However, it can be used for any similar purpose. The magic string and the file headers used by ar consist of printable ASCII characters. If an archive is composed of printable files, the entire archive is printable.

When ar creates an archive, it creates headers in a format that is portable across all machines. The portable archive format and structure are described in detail in ar(4) . The archive symbol table (described in ar(4) ) is used by the link editor ld to effect multiple passes over libraries of object files in an efficient manner. An archive symbol table is only created and maintained by ar when there is at least one object file in the archive. 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 accessible to the user. Whenever the ar command is used to create or update the contents of such an archive, the symbol table is rebuilt. The s option described below will force the symbol table to be rebuilt.

Options

The following options are supported:
-a
Position new files in archive after the file named by the posname operand.
-b
Position new files in archive before the file named by the posname operand.
-c
Suppress the diagnostic message that is written to standard error by default when 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 file names from replacing files with the same prefix.
-d
Delete one or more files from archive.
-i
Position new files in archive before the file named by the posname operand (equivalent to -b).
-m
Move files. If -a, -b, or -i with the posname operand are specified, move files to the new position; otherwise, move files to the end of archive.
-p
Print the contents of files in archive to standard output. If no files are specified, the contents of all files in archive will be written in the order of the archive.
-q
Quickly append files to the end of archive. Positioning options -a, -b, and -i are invalid. The command does not check whether the added files are already in archive. This option is useful to avoid quadratic behavior when creating a large archive piece-by-piece.
-r
Replace or add files in archive. If archive does not exist, a new archive file will be created and a diagnostic message will 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 will not change the order of the archive. If the -u option is used with the -r, option, then only those files with dates of modification later than the archive files are replaced. If the -a, -b, or -i option is used, then the posname argument must be present and specifies that new files are to be placed after (-a) or before (-b or -i) posname; otherwise the new files are placed at the end.
-s
Force the regeneration of the archive symbol table even if ar is not invoked with a option which will modify the archive contents. This command is useful to restore the archive symbol table after the strip(1) command has been used on the archive.
-t
Print a table of contents of archive. The files specified by the file operands will be included in the written list. If no file operands are specified, all files in archive will be included in the order of the archive.
-T
Allow file name 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 is an error; a diagnostic message will be written and the file will not be extracted.
-u
Update older files. When used with the -r option, files within archive will be replaced only if the corresponding file has a modification time that is at least as new as the modification time of the file within archive.
-V
prints its version number on standard error.

/usr/bin/ar

-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 the constituent files, and maintenance activity.

When used with -p, write the name of the file to the standard output before writing the file itself to the standard output.

When used with -t, include a long listing of information about the files within the archive.

When used with -x, print the filename preceding each extraction.

When writing to an archive, a message is written to the standard error.

/usr/xpg4/bin/ar

-v
Same as /usr/bin/ar version, except when writing to an archive, no message is written to the standrad error.
-x
Extract the files named by the file operands from archive. The contents of archive will not be changed. If no file operands are given, all files in archive will be extracted. If the file name of a file extracted from archive is longer than that supported in the directory to which it is being extracted, the results are undefined. The modification time of each file extracted will be set to the time file is extracted from archive.

Operands

The following operands are supported:
archive
A path name of the archive file.
file
A path name. Only the last component will be used when comparing against the names of files in the archive. If two or more file operands have the same last path name component ( basename(1) ), the results are unspecified. The implementation’s archive format will not truncate valid file names of files added to or replaced in the archive.
posname
The name of a file in the archive file, used for relative positioning; see options -m and -r.

Environment

See environ(5) for descriptions of the following environment variables that affect the execution of ar: LC_CTYPE , LC_MESSAGES , and NLSPATH .

Exit Status

The following exit values are returned:
  1. Successful completion.
    >0
    An error occurred.

    See Also

    basename(1) , cc(1B) , cpio(1) , ld(1) , lorder(1) , strip(1) , tar(1) , a.out(4) , ar(4) , environ(5)

    Notes

    If the same file is mentioned twice in an argument list, it may be put in the archive twice.

    By convention, archives are suffixed with the characters .a.


    Table of Contents