Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page



 

Linux / Unix ar command

Quick links

About ar
Syntax
Examples
Related commands
Unix main page

About ar

Maintain portable archive or library.

Syntax

ar [-d] [-m] [-p] [-q] [-t] [-x] [-r] [-a] [-b] [-c] [-C] [-F format] [-i] [-l] [-s] [-T] [-I] [-u] [-V] [-v] [ posname ] archive file

-d Deletes each named member from the archive and regenerates the symbol table.
-m Moves the named archive member in the archive. You indicate the new position for the member with -a, -b, or -i and posname; if you do not specify a location, ar moves the member to the end of the archive.
-p Displays each specified member on the standard output. If you do not specify any members, ar displays all members.
-q Quickly appends the specified file to the archive. ar does not check to see if file is already a member of the archive.
-t Displays a table of contents that lists member or every member if you do not specify a particular member. ar displays a diagnostic for each member that it cannot find. Normally, ar displays only the member's name, but with the verbose (-v) option, ar displays more information about archive members using a format similar to ls -l.
-x Extracts each specified member from the archive and copies it to a file. If you specify member as a full path name, ar copies it to that path name. If you do not specify a member, ar extracts all members. The archive remains unchanged.
-r Replaces or adds file to archive. If archive does not exist, ar creates it and prints a message. When ar replaces an existing member, it does not change the archive order. If file is not replacing a member, ar adds it to the end of the archive (unless you specify -a, -b, or -i). This option regenerates the symbol table.
-a Places file in archive after the member specified by posname. If you do not specify a member, ar adds file to the end of the archive.
-b Places file in archive before the member specified by posname. If you do not specify posname, ar adds file to the beginning of the archive.
-c Suppresses the message ar normally prints when it creates a new archive file. You can only use this in conjunction with the -r and -q options.
-C Prevents ar from overwriting existing files with extracted files. You can only specify this option when extracting files with the -x option.
-F format Specifies the archive format to be used by a new archive. Valid formats are omf and coff. You can only use this option when creating a new archive with the -r option or the -q option.
-i Inserts the file into the archive before the member specified by posname. If you do not specify posname, ar inserts file at the beginning of the archive. This option is the same as -b.
-I Ignores the case of letters when searching the archive for specified member names. Normally, the case is significant.
-l Puts any temporary files that ar generates in the current directory rather than the default temporary file directory.
-s Regenerates the symbol table regardless of whether the command modifies the archive.
-T When used with -x, allows extraction of members with names longer than the file system supports; normally, this is an error, and ar does not extract the file. Most file systems truncate the file name to the appropriate length.
-u Replaces the member only if the modification time of the file member is more recent than the time of the archive member. -u implies -r, so it is not necessary to specify -r also.
-V Prints its version number on standard error.
-v Gives verbose output. With -d, -q, -r, and -x, this option displays the command letter and the member name affected before performing each operation. With -t, it prints more information about archive members using a format similar to ls -l.  With -p, it displays the member name before the contents.
posname The name of a file in the archive file, used for relative positioning; see options -m and -r.
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), the results are unspecified. The implementation's archive format will not truncate valid file names of files added to or replaced in the archive.

Examples

ar r myfile.a 'ls *.o' - Replace myfile.a with object files in the current directory.

Related commands

basename
cc
cpio
ld
make
tar

 

Index

Category:
Linux / Unix

Companies:
Click here

Related Pages:

 

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope