Why is "tar" trying to create an empty archive?

3

I'm trying to use tar to tar files before transfer, so I can keep the entire file path rather than losing it along the way. However, when I try to tar an empty folder, it tells me that it is cowardly refusing to create an empty archive. I want to keep the empty folder on the other end, but don't want to put anything else into the archive to make it non-empty. Is there any way to do this?

snostorm

Posted 2010-04-21T01:53:13.687

Reputation: 133

1Works fine here. How are you doing it? – Ignacio Vazquez-Abrams – 2010-04-21T01:58:53.647

Answers

3

What command are you using? I am able to create a tar archive of an empty directory just fine:

[jnet@Stan tmp]$ mkdir test
[jnet@Stan tmp]$ tar -cf test.tar test
[jnet@Stan tmp]$ ls -lh test.tar 
-rw-r--r--  1 jnet  wheel    10K Apr 20 21:58 test.tar

Josh

Posted 2010-04-21T01:53:13.687

Reputation: 7 540

Looking at your answer, I realized I forgot the first argument... so this is really just an ID10T error.

Thanks for helping anyway! – snostorm – 2010-04-21T02:03:15.077

You know it's cowardly to create an empty archive right? ;-) – Josh – 2010-04-21T02:18:47.203

@josh: i'm pretty sure it was the refusal to create an empty archive that was "cowardly". tho i'm not remembering who says that. is that a tar error or somebody else? – quack quixote – 2010-04-21T03:15:02.713

snostorm@ubuntu:~$ tar -cf filename tar: Cowardly refusing to create an empty archive Try tar --help' ortar --usage' for more information. – snostorm – 2010-04-21T11:32:45.123

So that's a tar error. :) – snostorm – 2010-04-21T11:33:28.867

@quack quixo: Yeah, you're right, my joke didn't make too much sense... I tried! :-) – Josh – 2010-04-21T13:03:03.730