Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

compressing directories

Posted on 2001-07-26
10
Medium Priority
?
351 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
Industry Leaders: 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 200 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

Technology Partners: 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!

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

610 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