Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 991
  • Last Modified:

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 /)
0
ServerOverflow
Asked:
ServerOverflow
  • 2
1 Solution
 
tfewsterCommented:
Try the -C option to tar (if your version supports it)
`man tar` for details
0
 
tfewsterCommented:
e.g. tar cvf test.tar -C home/dummy  imageFolder
0
 
ServerOverflowAuthor Commented:
Thanks, I knew about that -C, but I had the syntax wrong, thanks for the example
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now