Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .