ar

NAME

ar - create and maintain library archives

SYNOPSIS

ar -d [-v] archive file ...
ar -m [-abilv] [posname] archive file ...
ar -p [-v] archive file ...
ar -q [ -clv] archive file ...
ar -r [-cuv] archive file ...
ar -t [-v] archive [file ...]
ar -x [-v] archive [file ...]
ar -M [mri-script]

DESCRIPTION

The ar(1) utility creates and maintains groups of files combined into an archive. After you have created an archive, you can use ar(1) to modify its contents by adding new files and by deleting, extracting, or replacing existing files.

The most common use of ar(1) is to combine object files into a library archive. If all of the specified files are valid object files, ar(1) automatically creates a library. If some of the specified files are not valid object files (for example, if they are text files), the library may not be valid.

The first option given to ar(1) specifies the type of action; the remaining options modify that action. The - may be omitted from the type of action.

The file can be a path name if the file is being added to the archive from the system (whether as a replacement or a new file). If the file is already stored in the archive (for example, when moving, deleting, or extracting), file should be the last component of the member's path name.

OPTIONS

-a
Add new files to the archive after the member file named by posname.
-b
Add new files to the archive before the member file named by posname.
-c
Suppress diagnostic message. Normally, ar(1) writes a message to standard error when archive is created. This option is only useful with -c and -r.
-C
When extracting files, protect existing files in the file system from being overwritten by members with similar names. This is particularly useful with the -T option, to prevent truncated file names from being overwritten by files with the same prefix.
-d
Delete one or more files from the archive.
-f
Truncate names of files being added to the archive. Normally, names of any length are allowed, but this option may be used if the native ar(1) on a system does not allow names of arbitrary length.
-i
Insert the new files to the archive before the member file named by posname (identical to -b).
-l
Work locally by placing the temporary file in the current directory, rather than in the directory specified by TMPDIR.
-m
Move the named files within the archive. Unless the -a, -b, or -i options are given, the files are moved to the end of the archive.
-M mri-script
Control the actions of ar(1) using a script, mri-script, or interactively if no argument is supplied. (This is similar to the MRI librarian program.) The scripting language is not described here, since this option does not provide all of the features of the command line. This option is for developers who already have scripts for the MRI librarian program, and is intended to make the migration to ar(1) easier.
-o
Preserve the original dates of members when they are extracted. Without this option, extracted members are given timestamps based on the time of extraction.
-p
Print the contents of the files from the archive to standard output. If no files are specified, print the entire contents of the archive. (For a list of the archive's contents, use -t.)
-P
Match the path names recorded in the archive. The LIB.EXE program can create archives that contain path names rather than file names. This option causes ar(1) to match on the full path name when looking up a name in the archive. (If -P is not used, only the file name component of any name is used for name matching, both for names on the command line and for member names.) When the -x directive is used, the selected member is extracted to the name given on the command line, whether -P is given or not.
-q
Quickly append the named files to the end of the archive without checking to see whether the files are already members of the archive. This option is useful when building a large archive a piece at a time.
-r
Replace or add the files to the archive. If the archive does not exist, create it. Files that are added (rather than replacing existing members) are added to the end of the archive.
-s
Write (or update) an index of the object files into the archive.
-t
Write the archive's table of contents to standard output. If no files are specified, all members are written; otherwise, only the specified files are written.
-T
Truncate file names if they are too long for the file system. Normally, ar(1) refuses to extract files if the names are too long.
-u
Update files. When this option is used with -r, ar(1) only replaces files if the modification time on the file is newer than the modification time of the archive member.
-v
Provide verbose output.
-V
Display the version number of ar(1).
-x
Extract the named files from the archive. The archive itself is not changed. If the file name is too long for the current file system, it is not extracted. If no files are specified, all files are extracted.

DIAGNOSTICS

Ar(1) can return one of the following exit values:

0
Success.
>0
An error occurred.

ENVIRONMENT VARIABLES

Ar(1) uses the following environment variable, if set:

TMPDIR
Use this directory, rather than the default, for temporary files.

SEE ALSO

c89(1)