Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a file that contain list of files I want to archive with tar. Let's call it mylist.txt

It contains:

/path1/path2/file1.txt
/path1/path2/file3.txt
...
/path1/path2/file10.txt

What I want to do is to archive this file into a tarball but excluding /path1/path2/. Currently by doing this:

tar -cvf allfiles.tar -T mylist.txt

preserves the path after unarchiving.

I tried this but won't work too:

tar -cvf -C /path1/path2 allfiles.tar -T mylist.txt

It archives all the files in /path1/path2 even those which are not in mylist.txt

Is there a way to do it?

share|improve this question

1 Answer 1

Maybe you could try with the --exclude parameter of tar :

tar -cvf allfiles.tar -T mylist.txt --exclude=/path1/path2
share|improve this answer
    
Thanks. Tried that. It still won't do. The path still preserved. –  neversaint Nov 7 '11 at 22:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.