Operating System - HP-UX
1833870 Members
1740 Online
110063 Solutions
New Discussion

Extract data that exclude some directories using tar command

 
ajk_5
Frequent Advisor

Extract data that exclude some directories using tar command

Dear all,

I want to use tar extracting data from tape that exclude some directories. Could you tell me how I can do it?
Thanks very much.

Best Regards
Ajk
5 REPLIES 5
V.Tamilvanan
Honored Contributor

Re: Extract data that exclude some directories using tar command

Hi,
There is no option in tar to exclude selected directories.
You can do it on the other way by selecting whatever the directories to be extracted.
You first create a list of files archived and extract the directories whatever u required from the list.

1. #tar -tvf /dev/rmt/1m >logfile

2.#tar -xvf /dev/rmt/1m /usr1 /usr2


HTH
Robert-Jan Goossens
Honored Contributor

Re: Extract data that exclude some directories using tar command

Hi,

believe you can use pax,

# pax -pe -rvf /tarfile.tar -s '/^\///' /dir1 /dir2

Look at the man page of pax.

Hope it helps,

Robert-Jan.
Mad_1
Regular Advisor

Re: Extract data that exclude some directories using tar command

Try the tar download from the "Software Porting And Archive Centre for HP-UX" from below link.

http://hpux.connect.org.uk/hppd/hpux/Gnu/tar-1.13.25/
Ravi_8
Honored Contributor

Re: Extract data that exclude some directories using tar command

Hi,

you can do this using GNU tar, look at the URL given by Mad
never give up
Chris Vail
Honored Contributor

Re: Extract data that exclude some directories using tar command

There's no way to do this using tar exactly. What you can do is extract the filenames into a text file, then edit the text file and delete out the files you don't want. Then you can use that text file as an argument to another tar command:
tar tvf /dev/rmt/0>/tmp/tarnames
vi /tmp/tarnames
tar xvf /dev/rmt/0 `cat /tmp/tarnames`

Other tar variants can do this as you want it to: Backup Edge, a 3rd party product, is one of them.


Chris