Solved

compressing directories

Posted on 2001-07-26
10
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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.

726 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