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

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".


Tar option summary

Y'all are welcome to edit this to add more esoteric switches but here are the basics:

  • x - extract files
  • c - create archive
  • t - list files
  • v - verbose (list files as it processes them)
  • j - use bz2 compression
  • z - use gz compression
  • f - read or write files to disk

Examples

Uncompress a tar.gz file: tar zxf tarball.tar.gz

Uncompress a tar.bz2 file: tar jxf tarball.tar.bz2

Create a tar.gz file: tar zcvf tarvall.tar.gz mydir/*


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).