AR(1)

πŸ“¦ version 1.053, in alpine 3.24

πŸŽ€ AR(1) πŸŽ€

(from the User Contributed Perl Documentation corner of the group chat β€” yes bestie, we're doing archive girl summer.)

🌸 NAME 🌸

ar β€” create and maintain library archives

πŸ¦‹ SYNOPSIS πŸ¦‹

     ar -d [-v] archive file ...
     ar -m [-v] archive file ...
     ar -m [-abiv] position archive file ...
     ar -p [-v] archive [file ...]
     ar -q [-cv] archive file ...
     ar -r [-cuv] archive file ...
     ar -r [-abciuv] position archive file ...
     ar -t [-v] archive [file ...]
     ar -x [-ouv] archive [file ...]

πŸ’– DESCRIPTION πŸ’–

okay so the ar utility creates and maintains groups of files combined into an archive. once an archive has been created, new files can be added and existing files can be extracted, deleted, or replaced. it's giving "little file bag with main character energy." 🫢

Files are named in the archive by a single component, i.e., if a file referenced by a path containing a full pathname is archived it will be named by the last component of that path. When matching paths listed on the command line against file names stored in the archive, only the last component of the path will be compared. iykyk? that's the vibe check. ✨

If multiple files in the archive have the same name, and paths are listed on the command line to select archive files for an operation, only the first file with a matching name will be selected. no cap, just the first one.

The normal use of ar is for the creation and maintenance of libraries suitable for use with the loader (see ld(1)) although it is not restricted to this purpose. so it's iconic for libraries, but it can also do other stuff. periodt. πŸ‘‘

✨ OPTIONS ✨

ar accepts the following options:

  • -a β€” a positioning modifier used with the options -r and -m. The files are entered or moved after the archive member position, which must be specified.
  • -b β€” a positioning modifier used with the options -r and -m. The files are entered or moved before the archive member position, which must be specified.
  • -c β€” whenever an archive is created, an informational message to that effect is written to standard error. If the -c option is specified, ar creates the archive silently. 🀫
  • -d β€” delete the specified archive files.
  • -i β€” identical to the -b option. literally same.
  • -m β€” move the specified archive files within the archive. If one of the options -a, -b or -i is specified, the files are moved before or after the position file in the archive. If none of those options are specified, the files are moved to the end of the archive.
  • -o β€” set the access and modification times of extracted files to the modification time of the file when it was entered into the archive. This will fail if the user is not the owner of the extracted file or the super-user. ⚠️
  • -p β€” write the contents of the specified archive files to the standard output. If no files are specified, the contents of all the files in the archive are written in the order they appear in the archive.
  • -q β€” (quickly) append the specified files to the archive. If the archive does not exist a new archive file is created. Much faster than the -r option, when creating a large archive piece-by-piece, as no checking is done to see if the files already exist in the archive. slay for speed. πŸ”₯
  • -r β€” replace or add the specified files to the archive. If the archive does not exist a new archive file is created. Files that replace existing files do not change the order of the files within the archive. New files are appended to the archive unless one of the options -a, -b or -i is specified.
  • -t β€” list the specified files in the order in which they appear in the archive, each on a separate line. If no files are specified, all files in the archive are listed.
  • -u β€” update files. When used with the -r option, files in the archive will be replaced only if the disk file has a newer modification time than the file in the archive. When used with the -x option, files in the archive will be extracted only if the archive file has a newer modification time than the file on disk.
  • -v β€” provide verbose output. When used with the -d, -m, -q or -x options, ar gives a file-by-file description of the archive modification. This description consists of three, white-space separated fields: the option letter, a dash (-) and the file name. When used with the -r option, ar displays the description as above, but the initial letter is an a if the file is added to the archive and an r if the file replaces a file already in the archive.
    • When used with the -p option, the name of each printed file, enclosed in less-than (<) and greater-than (>) characters, is written to the standard output before the contents of the file; it is preceded by a single newline character, and followed by two newline characters.
    • When used with the -t option, ar displays an ls -"l"-style listing of information about the members of the archive. This listing consists of eight, white-space separated fields: the file permissions, the decimal user and group ID's, separated by a single slash (/), the file size (in bytes), the file modification time (in the date(1) format %b %e %H:%M %Y), and the name of the file.
  • -x β€” extract the specified archive members into the files named by the command line arguments. If no members are specified, all the owner and group will be unchanged. The file access and modification times are the time of the extraction (but see the -o option). The file permissions will be set to those of the file when it was entered into the archive; this will fail if the user is not the owner of the extracted file or the super-user.

ar exits 0 on success, and >0 if an error occurs. periodt. πŸ’…

🌈 ENVIRONMENT 🌈

The working of ar is not influenced by any environment variables. literally none. the environment said "not today." 🧚

πŸ’€ BUGS πŸ’€

  • ar uses POSIX::strftime(), which isn't part of the basic distribution.
  • The entire archive is loaded into memory, which could be slow or exhaust memory. 😭
  • The "-tv" option does an "ls -"l""-style output, but the interpretation of the mode bits is probably not portable.
  • ar doesn't check for bogus minor options that don't make sense with a major option -- they're just ignored. no cap, ignored.

This program is copyright by dkulp 1999.

This program is free and open software. You may use, copy, modify, distribute and sell this program (and any modified variants) in any way you wish, provided you do not restrict others to do the same.


πŸ’– okay bestie, that's the whole ar(1) page β€” AR(1), if we're being loud about it. written against perl v5.42.2, dated 2026-02-15 β€” mwah πŸ’–

πŸ“¦ where this page comes from