Home » Questions » Computers [ Ask a new question ]

Untar, ungz, gz, tar - how do you remember all the useful options?

Untar, ungz, gz, tar - how do you remember all the useful options?

I am pretty sure I am not the only one with the following problem: every time I need to uncompress a file in *nix I can't remember all the switches, and end up googling it, which is surprizing considering how often I need to do this.

Asked by: Guest | Views: 281
Total answers/comments: 5
Guest [Entry]

"Or how about using the shell with advanced completion capabilities (like zsh or fresh versions of bash) which will complete the options for you, with comprehensive help? :))

Regarding tar: just look at the ""qwerty"" keyboard. There are letters ""zxcvf"" next to each other. You need either ""tar czvf file.tar.gz files"" or ""tar xzvf file.tar.gz""."
Guest [Entry]

"There's a small Perl script called ""unp"".

unp filename.tar.gz

...and it extracts everything. Works with any compressed file as long as you have the right binaries. And you just forget about syntax or any of that crap. Check your Linux distribution's repositories. It should be there (at least on Arch, Debian and Ubuntu)."
Guest [Entry]

"If you have trouble remembering the tar options, try using pipes:

zcat file.tar.gz | tar xvf -
bzcat file.tar.bz2 | tar xvf -

Replace tar xv with tar tv to just view the tarball's contents.

Personally, I use the following mnemonics:

t, x, or c for ""tabulating"", ""xtracting"", or ""creating"", respectively.
v for listing all the files.
z, j, or nothing for tar.gz, tar.bz2, or plain .tar, respectively.
f for giving a filename, vs. the default of using stdin/stdout or a tape device.

Although ""j"" and ""bzip2"" seem to have nothing to do with each other, I find it easy to remember this exception.

Also, I find it funny that Googling has replaced ""man tar""."
Guest [Entry]

"Man is your friend.

man tar"
Guest [Entry]

"The Three Most Frequently Used Operations:

--create -c

Create a new tar
archive.

--list -t

List the contents of an archive.

--extract -x

Extract one or more members from an archive.

The Five Advanced tar Operations:

--append -r

Add new entries to an archive that already exists.

--update -u

Add more recent copies of archive members to the end of an archive, if they exist.

--concatenate --catenate -A

Add
one or more pre-existing archives to
the end of another archive.

--delete

Delete items from an
archive (does not work on tapes).

--compare --diff -d

Compare
archive members to their counterparts
in the file system."