Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
$ tar -zcvf archive/test.tar.gz files

will give me as below :



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

will give me as below :


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

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

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

Your Answer


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.