Solved

compressing directories

Posted on 2001-07-26
10
338 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now