Link to home
Start Free TrialLog in
Avatar of ServerOverflow
ServerOverflow

asked on

tar command and relative paths

Ok I have a tar-ing problem was wondering if someone could help...

If I have a tar that contains a bunch of files like:
home/dummy/imageFolder/blah.tif
home/dummy/imageFolder/blah2.tif
home/dummy/imageFolder/subDir
home/dummy/imageFolder/subDir/blah5.tiff
...

is there a way to extract all the files/dirs in the imageFolder without having tar make the complete dir home/dummy/imageFolder

(when i run "tar -xvf mytar.tar" it makes the complete dir path from where ever I ran it...)


OR if this isn't possible, is there a way to tar a folder using a complete path /home/blah/blah/myFolder but so that the path in the tar is just myFolder/ , that way the extraction wont make that complete path when I call it...



Thanks for your time.

PS. (please dont tell me I should cd to the dir, I know this, but Im doing some remote programming, and the cd command is not a valid option, everything is being done using absolute paths from /)
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Try the -C option to tar (if your version supports it)
`man tar` for details
ASKER CERTIFIED SOLUTION
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ServerOverflow
ServerOverflow

ASKER

Thanks, I knew about that -C, but I had the syntax wrong, thanks for the example