The Linux ar command is used to create or modify a file to be kept, or to extract files from the file to be kept.
Ar allows you to collect a large number of files into a single file. All member files keep their original attributes and permissions.
Syntax
Ar [-dmpqrtx] [cfosSuvV] [a <member files>] [B <member files>] [I <member files>] [keep files] [member files]
Parameters:
Required parameters:
- -D. Delete the member files in the keep file.
- -M: change the order in which member files are stored.
- -P: displays the content of the member file in the file.
- -Q will append the user to the end of the file to be kept.
- -R: Insert the file into the storage file.
- -T displays the files contained in the kept files.
- -X Saves the member files in your own files.
Option parameters:
- A <member File> Insert the file into the specified member file in the keep file.
- B <member File> before inserting a file into a specified member file in the kept file.
- C. Create and keep documents.
- F. To prevent too long file names from being compatible with ar commands of other systems, you can use this parameter to cut down the names of long member files to be placed in the files.
- I <member files> before you insert a specified member file in the kept file.
- O preserve the date on which files are kept.
- S if the file to be kept contains the object mode, you can use this parameter to create a symbol table for the file to be kept.
- S does not generate a symbol table.
- U only inserts new files with a specified date into the keep file.
- Detailed information is displayed when the v program is executed.
- V displays the version information.
Instance
Package files
Root@w3cschool.cc ~ # Ls // display the current directory file a. cb. c d. c install. log qteanaconda-ks.cfg c. c Desktop [root@w3cschool.cc ~] # Ar rv one. bak. c B. c // package. c B. c file ar: creating one. baka-. ca-B. c [root@w3cschool.cc ~] #
Package multiple files
Root@w3cschool.cc ~ # Ar rv two. bak *. c // package. file ar ending with c: creating two. baka-. ca-B. ca-c. ca-d. c [root@w3cschool.cc ~] #
Display package content
Root@w3cschool.cc ~ # Ar t two. bak a. cb. cc. cd. c [root@w3cschool.cc ~] #
Delete the member file of the package.
Root@w3cschool.cc ~ # Ar d two. bak a. c B. c. c [root@w3cschool.cc ~] # Ar t two. bak d. c