Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
I noticed when I make a tar archive, it includes the full path, ex, if I tar the files in /usr/include/folder to folder.tar.gz, when I untar that file, it actually contains a folder called usr, then includes, then folder, then finally my files. How do I make it so the files are at the root of the tar archive?
 

Colt45

Lifer
Apr 18, 2001
19,720
1
0
cd to /usr/include first?


or..
tar -vcf <outputfile.tar> -C /usr/include/ <folder>

the -C makes tar act if it was in /usr/include/ even if it isnt. The file will still be saved to whatever dir you called tar from (say home, or whatever) [this will make the tar be folder/file1 folder/file2, etc.]

and if you want no folder at all:
tar -cf out.tar -C /usr/include/folder .

note the '.'

I usually just do this though:
cd /usr/include/folder
tar -cf ~/out.tar .

not sure why.