📅 2020-Jun-17 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ ar, cheatsheet ⬩ 📚 Archive
ar is the classic Unix/Linux tool used to work with archive files. An archive file is typically used for a static library, holding a collection of
.o object files and typically has the file extension
.a. The files inside an archive are called its members.
On Linux, it ships as part of the GNU Binutils.
$ ar -cr foobar.a
Note that providing just
-c does not work: it has to be used along with a member operation like
$ ar -cr foobar.a member1.o member2.o member3.o
The comparison for replacement is done based on member filename only, not on the size or contents of the members. The archive will store the members in the order they are inserted.
$ ar -x foobar.a
$ ar -xv foobar.a
$ ar -x foobar.a member1.o member2.o member3.o
$ ar -t foobar.a
This option is confusingly named
-t instead of
-l (for list). An easy way to remember this option is to think about it as printing a table of members.
$ ar -tv foobar.a
.debfile is also actually an archive file. So all the actions above can be used on these files too.
Tried with: Binutils 2.30 and Ubuntu 18.04