1835267 Members
2487 Online
110078 Solutions
New Discussion

Re: find and compress

 
eric stewart
Frequent Advisor

find and compress

I have a directory with 986 files in it.
If I do find . -type f -exec compress -f {} \;
It will not work consistantly.
Here are the number of files compressed in 7 runs:
265, 784, 264, 519, 264, 264, 980.
Is there something about find and compress that do not go together?
This was uncovered when I was compressing files in a laarge file system.
If I use compress * in the current directory it compresses all the files.
If I go to the higher level directory (test) and use find test -type f ... It also does not compress all the files.
As a side note. Every once and a while compress will tell me that some of the files are already compressed.
DO my problems come about because the find command uses the directory list which compress updates because the inode of the compressed files would be different that the uncompressed?
Good help is easy to find within forums
4 REPLIES 4
Rodney Hills
Honored Contributor

Re: find and compress

I'm not sure of any issues with find and compress, but have you tried using
compressdir -f .

If you are running compress multiple times on the same directory, I think you might not get what you expect.
There be dragons...
eric stewart
Frequent Advisor

Re: find and compress

Rodney,
I did not know about compressdir when I was doing the find.
I have tried compressdir -f abd it also does not work.
I was not trying to do multile compress at the same time on the same directory.
Tx eric
Good help is easy to find within forums
Rodney Hills
Honored Contributor

Re: find and compress

I would try seperating into 2 commands-
find . -print >/tmp/myfiles
cat /tmp/myfiles | xargs -n1 compress -f

Maybe when the directory is large, find gets lost walking the directory when compress puts the compressed files back into the same directory.
There be dragons...
Chris Calabrese
Valued Contributor

Re: find and compress

First, compress will not re-compress already compressed files, so that gets you:

find . -type f ! -name "*.Z" -exec compress {} \;

Next, compress will not
compress files for which
there is no advantage (i.e.,
the compressed version won't
actually be smaller). You can
override this with -f, or

find . -type f ! -name '*.Z" -exec compress -f {} \;

As for using xargs, that's
usually OK, but breaks down
when files have newline char's
in their names (admitedly rare).
Brainbench MVP for Unix Administration and Internet Security, SANS Review Editor, and Center for Internet Security HP-UX Benchmark project leader