Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
$ tar -zcvf archive/test.tar.gz files

will give me as below :

files/
files/1
files/2
files/3

--

$ tar -zcvf archive/test.tar.gz -C files .

will give me as below :

./
./1
./2
./3

I am not able to figure out the right tar command for an output as below .

1
2
3
share|improve this question
    
Have you tried untaring your archive? I think you'll find the files have been tared the way you want. –  bryan Apr 20 '12 at 20:41
    
yeah , i did , thing is .. I expect the tar.gz to have no "." in its directory structure –  HelloWorld_Always Apr 20 '12 at 20:43
    
"." just means the files will extract to the current directory. –  bryan Apr 20 '12 at 20:45
add comment

1 Answer 1

tar ... -C files . already does what you want.

Since . refers to the current directory, the file names "1" and "./1" are exactly the same thing.

With at least GNU tar, to completely remove file paths you will have to give the filenames in command line or via -T: tar c ... file1 file2 file3. This however gives no practical advantage over just having ./file1 in the tarball.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.