1

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?

1

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

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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