Compressing a Directory Tree: Fine-Tuning (Unix Power Tools, 3rd Edition)
15.9. Compressing a Directory Tree: Fine-Tuning
Here's
a quick little command that will compress (Section 15.6) files
in the current directory and below. It uses find (Section 9.2) to
find the files recursively and pick the files it should compress:
-sizeSection
9.14, xargs Section 28.17
% find . ! -perm -0100 -size +1 -type f -print | xargs gzip -v
This command finds all files that are the following:
Not executable (! -perm
-0100), so we don't compress
shell scripts and other program files.
Bigger than one block, since it won't save any disk
space to compress a file that takes one disk block or less. But,
depending on your filesystem, the -size +1 may not
really match files that are one block long. You may need to use
-size +2, -size +1024c, or
something else.
Regular files (-type f) and not
directories, named pipes, etc.
The -v switch to gzip tells you
the names of the files and how much they're being
compressed. If your system doesn't have
xargs, use the following:
% find . ! -perm -0100 -size +1 -type f -exec gzip -v {} \;
Tune the find expressions to do what you want.
Here are some ideas -- for more, read your
system's find manual page:
! -name \*.gz
Skip any file that's already
gzipped (filename ends with
.gz ).
-links 1
Only compress files that have no other (hard) links.
-user yourname
Only compress files that belong to you.
-atime +60
Only compress files that haven't been accessed
(read, edited, etc.) for more than 60 days.
You might want to put this in a job that's run every
month or so by at (Section 25.5) or cron
(Section 25.2).
-- JP
15.8. How Much Disk Space?15.10. Save Space in Executable Files with strip
Copyright © 2003 O'Reilly & Associates. All rights reserved.
Wyszukiwarka
Podobne podstrony:
ch15 (7)ch15ch15ch15ch15CH15 (2)ch15CH15 (18)ch15 (28)ch15ch15 (10)ch15ch15ch15ch15ch15 (3)ch15więcej podobnych podstron