ztar - my wrapper on tar -z


29th of June 2005

Something I find myself doing very often is to download a .tar.gz or .tgz file that I want to unpack, but only in a subfolder. Some rather annoying gzips aren't collected in one folder so that when you unpack it lots of files are created in the current directory. Do you find yourself often doing this:

 $ tar -ztvf Some-0.x.tar.gz
 Some/file1.txt
 Some/file2.txt
 ...
 Some/file100.txt
 $ tar -zxvf Some-0.x.tar.gz
 Some/file1.txt
 Some/file2.txt
 ...
 Some/file100.txt

Or, in case they the gzip is badly organised:

 $ tar -ztvf Foo-0.y.tar.gz
 file1.txt
 file2.txt
 ...
 file100.txt
 $ mkdir Foo; mv Foo-0.y.tar.gz Foo/; cd Foo/
 $ tar -zxvf Foo-0.y.tar.gz
 file1.txt
 file2.txt
 ...
 file100.txt
 $ cd ..

If you feel that this is too much typing, consider my little (python) script so that you can do this:

 $ ztar Some-0.x.tar.gz
 Some/file1.txt
 Some/file2.txt
 ...
 Some/file100.txt
 $ ztar Foo-0.y.tar.gz
 Not tarred in one single folder. Create a new one?
 Folder: Foo
 Foo/file1.txt
 Foo/file2.txt
 ...
 Foo/file100.txt 

The ztar program is a little Python script that wraps up all of these alternatives and options into one little program. Drawback: you get used to it and all of a sudden it's not there because it's not part of the the standard bash utils.

To make this happen on your Linux system, download the file and make it executable. Stick it in your global or local bin directory and enjoy. Remember, this is not rocket science and it welcomes feedback.



Comment

Show all 9 comments
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.