Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

excluding files from a list

 
SOLVED
Go to solution
Highlighted
puth
Occasional Advisor

excluding files from a list

i have two files
file A- one with the list of the files to be tarred and the file B -list of the files to be excluded from A before tarring.

Can any one help me on how to pass my exclude file list while tarring?

I know that linux has -X option but i am using HP systems and there is no -X option on HP.

Any help would be highly appreciated.
6 REPLIES 6
Highlighted
James R. Ferguson
Acclaimed Contributor

Re: excluding files from a list

Hi:

Since you have an include and an exclude list in two files, construct a third file to pass along to 'tar'. The following assumes that the two input files are sorted. The output will be only lines from the first file that are not in the second file:

# comm -23 file1 file2 > file3

Regards!

...JRF...
Highlighted
puth
Occasional Advisor

Re: excluding files from a list

Thanks James for the reply..Your answer has helped me to an extend...

comm is removing the files in the file2 list but not the directories.Is the any possible way to remove the directories also?
Highlighted
James R. Ferguson
Acclaimed Contributor
Solution

Re: excluding files from a list

Hi (again):

> comm is removing the files in the file2 list but not the directories.Is the any possible way to remove the directories also?

I think you mean a situation like this:

# cat f1
/path/to
/path/to/somefile
/path/to/someotherfile
file1
file2
file3
file4
file5
file6

# cat f2
/path/to
file1
file3
file5

...and then:

# grep -vF -f f2 f1
file2
file4
file6

Regards!

...JRF...
Highlighted
puth
Occasional Advisor

Re: excluding files from a list

Yes
Highlighted
Steven Schweda
Honored Contributor

Re: excluding files from a list

> [...] there is no -X option on HP.

There is, if you install GNU "tar".

http://www.gnu.org/software/tar/
Highlighted
Dennis Handly
Acclaimed Contributor

Re: excluding files from a list

>there is no -X option on HP.

Instead of tar, on 11.31 you can use pax:
pax -x pax -o graph=graph_file