tar

Pack many files into one archive, then unpack it

About

The classic tape-archiver, now the standard way to pack a directory tree into one stream. Add a compressor and you get the familiar .tar.gz bundles. Use it to move or back up a hierarchy while keeping permissions and timestamps.

Install it

pkg install tar

Run this inside Termux. If the package is already present, pkg will say so and do nothing.

Commands worth knowing

6 of the invocations you will actually reach for. Tap the copy button to put one on your clipboard.

tar -czf snapshot.tgz notes/ Create a compressed archive, snapshot.tgz, from the notes folder.
tar -xzf snapshot.tgz Unpack the compressed archive into the current directory.
tar -tzf snapshot.tgz List the contents without extracting. See what is inside first.
tar -cjf photos.tbz Pictures/ Build an archive with the bzip2 compressor, chosen by the extension.
tar -xzf snapshot.tgz -C /sdcard/Download Extract into a chosen destination rather than the working directory.
tar --exclude="*.log" -czf clean.tgz project/ Build an archive while skipping anything that matches the pattern.

Worked example

Run tar -tzf snapshot.tgz and this is what you should see.

termux
$ tar -tzf snapshot.tgz
notes/
notes/todo.md
notes/ideas.md
notes/archive/2024.md

Developed by

GNU Project .