• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

compressing directories

Is there a way to compress an entire directory and all of it's subdirectories with 1 command?  Rather than going to each directory and compressing it.
0
mmssi
Asked:
mmssi
  • 5
  • 4
1 Solution
 
biraCommented:
Yes

  Suppose the dir you want to compreess is "yourdir"

  find yourdir  -print |cpio -ov > compressed.file


  The file compressed.file will contain yourdir and its
  subdirectories in a cpio format.

  Regards
0
 
biraCommented:
When you want to decompress, use

 cpio -id < compressed.file
0
 
paulqnaCommented:
as well as :

compress:
tar zcvf dirdate.tgz ./dir

uncompress:
tar zxvf dirdate.tgz
or
zcat dirdate.tgz | tar xvf -

But the cpio will work as well, don't know if that one will also remove the original directory ?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
biraCommented:
Cpio will work well if so.
0
 
mmssiAuthor Commented:
say I have a directory called /home/test.   I want to compress all the files and subdirectories and files in those subdirectories, but I do NOT want to archive them in 1 cpio or tar file.  Just compress the files in the /home/test and all subdirectories.....


0
 
biraCommented:
cd yourdir
gzip -r *
0
 
mmssiAuthor Commented:
cool that works.  Will gunzip -r * uncompress or unzip the same way that gzip -r * does to all files and directories?

0
 
biraCommented:
Yes
   enter
          gzip -dr *


0
 
mmssiAuthor Commented:
cool. That works.
0
 
mmssiAuthor Commented:
that worked great.  thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now