• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tar Command - Compress empty directories  RSS feed

 
Clarice Doe
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume that I have the following directory structure



When I say

the resulting something.tar file, doesn't contain the folder two, since that folder is empty. How can I get tar the entire tree, even if the folder is empty?
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think something must be wrong with your "tar" command. the example you listed works fine for me, and the resulting tarball contains an empty directory "x/y/two".

for reference, i'm using GNU "tar" version 1.13.25 on Mandrake Linux 9.2.
 
Peter Rooke
Ranch Hand
Posts: 900
7
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I tried this earlier, I tar'ed up empty directories no problem. I used SuSE Linux. Which operating system are you using?

Just a thought - you do have permissions to the empty directory? Is the problem directory a symbolic link?
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could be mistake about this, but the ability to archive "empty" directories was not fixed/implemented until after version 1.12 or 1.11.

Like I said I could be mistaken about this, but I suggest you check your version and possibly uprade to the current version and see if that fixes it.
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For example, I work on a Unix(HP) box, it is installed with the tar command. I tried the same command, it did not archive empty directories for me either. I have a linux server at home, but naturally I am unable to test it at this time.

So there could be an issue with which environment or version of tar you are using?
 
Peter Rooke
Ranch Hand
Posts: 900
7
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrh HP-UX, that will explain it
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't there an option to - extract/ not extract - empty directories?
Perhaps it's there, but not extracted?

However, my current linux-tar compresses, lists and extracts empty dirs by default.
 
Clarice Doe
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the replies.
I got the problem. The issue is that the tar compresses empty folders. But when I transfer it to Windows system, and extract it using WinZip, the empty folders are missing (WinZip is not showing the empty folders, even when I view the contents of the tar file).
Now, how can I extract the tar file in Windows, with out any problem?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!