Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to tar

📅 2015-Jan-22 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ tar, untar ⬩ 📚 Archive

Tape ARchive (TAR) is an classic file format that is used to archive files. Note that it does not compress the files to save space. Rather it is only for convenience of handling a single archive file instead of dealing with thousands of files. I typically use it to quickly move directories containing large number of small files.

$ tar -cf foobar.tar foobar1.txt foobar2.txt
$ tar -cf foobar.tar foobar
$ tar -cvf foobar.tar foobar
$ tar -xf foobar.tar
$ tar -xf foobar.tar --exclude exclude1
$ mkdir foobar
$ tar -xf haha.tar --directory foobar
$ tar -xf haha.tar -C foobar
$ tar -xf haha.tar
Writes out foo/bar/rocky/zoo.py

$ tar -xf haha.tar --strip-components 2
Writes out rocky/zoo.py
$ tar -xvf foobar.tar
$ tar -tvf foo.tar

Tried with: Tar 1.27.1 and Ubuntu 14.04