Checking tarball contents before extraction | Comments (2)
Posted in Code, Linux/Unix on 10th November 2008, 6:05 pm by Stuart
When you are about to unpack a tarball you didn’t create it’s a good idea to run the -t flag instead of just assuming it’s been packed in a sensible way.
tar -tzf foo.tar.gz
This lists all of the files in the tarball so you can be sure it’s not going to extract to somewhere you didn’t expect.
If you need tar to extract to a different location then you can use the -C flag to tell tar to cd to that directory first and then unpack the contents there.

Use atools. It comes with apack and aunpack. Now you no longer need to remember the different options for tar, unzip, zip, rar, bz2 etc.
Plus it ALWAYS puts things in a directory if the there are more than one file in the archive.
To unpack
$ aunpack foo.tgz
$ cd foo
To pack
$ apack files.zip /home/peterbe/files
@Peter: Nice tip thanks