Play with compressed tar files

Time to time every system administrator or user should extract file or entire archive from compressed tar, but quite often in filesystems there is not enough free space. In this case it's possible to extract file(s) on the fly without first uncompress and then untar:

gzip -dc archive.tar.gz|tar xf -

The above line can be modified when you should deal with broken archives. If you try to decompress such archive gzip just stop when find error in compression. But you want to save what's possible. So let's make it on this way:

cat archive.tar.gz|gzip -dc|tar xf -

I know it is possible to use GNU tar to extract files from compressed archive, but in UNIX world you can't be sure this software is installed :-)

Few remarks:
  1. It's wise to use 'f -' key because in some Unixes without explicit 'f' tar will use tape device or whatever is defiined in TAPE variable
  2. In above examples beside less diskpace usage you benefit from parallel execution (from pipe)

No comments:

Post a Comment

Should I trust AI

 Should I trust AI? So far no, sorry.  I tested for the moment (May, 2025) most advanced model for programming and ask very simple question:...