tags:

views:

29

answers:

1

Anybody know if it is possible that when making a tar + gzip through 'tar c ...' command if the relative paths will be ignored upon expanding.

e.g.

tar cvf test.tgz foo ../../files/bar

and then expanding the test.tgz with:

tar xvf test.tgz

gives a dir containing: foo files/bar

i want the dir to contain the files foo bar

is this possible?

+2  A: 

If all the paths begin with the same initial list of directories then you can use e.g. tar cvf test.tgz -C ../.. other/dir. Beware that the shell won't expand wildcards in pathnames "properly" however because -C asks tar to change directory.

Otherwise, the only way I've ever come up with is to make a temporary directory filled with appropriate symlinks and use the -h option to dereference through symlinks. Of course that won't work if some of the files you want to store are actually symlinks themselves.

j_random_hacker