• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tar Command - Compress empty directories

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1152
20
Mac OS X IntelliJ IDE Oracle Spring VI Editor Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1152
20
Mac OS X IntelliJ IDE Oracle Spring VI Editor Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arrh HP-UX, that will explain it
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
What are your superhero powers? Go ahead and try them on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic