Playing with tar

Every sysadmin know that tar program do not accept wildcards for extract files so if you want to extract only one or few files you should play with construction like this:
 tar xvf archive.tar `tar tvf archive.tar|grep string` 
But on complex requests will be need to do it several times and if archive reside on tape (do not forget from where come the name of utility tar) this can take long time. Instead is much better to deal with files:
tar tvf archive.tar>/tmp/somefilename 
make some filtering on the listing
tar xvf archive.tar `cat /tmp/somefilename` 
P.S. I use cat to make command work independently (almost) of version of tar, UNIX flavour or Linux

No comments:

Post a Comment

Compressed tar archive

There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar arc...