tags:

views:

33

answers:

1

I am running a PHP script that gets me the absolute paths of files I want to tar up. This is the syntax I have:

tar -cf tarname.tar -C /www/path/path/file1.txt /www/path/path2/path3/file2.xls

when I untar it create the absolute path to the files. I do I get just /path with everything under it to show?

+4  A: 

If you want to remove the first n leading components of the file name, you need strip-components. So in your case, on extraction, do

tar xvf tarname.tar --strip-components=2

The man page has a list of tar's many options, including this one. Some earlier versions of tar use --strip-path for this operation instead.

ire_and_curses
dunno how i missed it. thanks.
Angel S. Moreno