Solved

compressing directories

Posted on 2001-07-26
10
343 Views
Last Modified: 2010-04-21
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
Comment
Question by:mmssi
  • 5
  • 4
10 Comments
 
LVL 6

Expert Comment

by:bira
ID: 6323074
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
 
LVL 6

Expert Comment

by:bira
ID: 6323103
When you want to decompress, use

 cpio -id < compressed.file
0
 
LVL 5

Expert Comment

by:paulqna
ID: 6323944
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Expert Comment

by:bira
ID: 6323979
Cpio will work well if so.
0
 

Author Comment

by:mmssi
ID: 6324080
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
 
LVL 6

Accepted Solution

by:
bira earned 50 total points
ID: 6324216
cd yourdir
gzip -r *
0
 

Author Comment

by:mmssi
ID: 6324485
cool that works.  Will gunzip -r * uncompress or unzip the same way that gzip -r * does to all files and directories?

0
 
LVL 6

Expert Comment

by:bira
ID: 6324536
Yes
   enter
          gzip -dr *


0
 

Author Comment

by:mmssi
ID: 6324645
cool. That works.
0
 

Author Comment

by:mmssi
ID: 6324648
that worked great.  thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question