Operating System - HP-UX
1752754 Members
4698 Online
108789 Solutions
New Discussion

Re: the use of find command

 
NDO
Super Advisor

the use of find command

Hi All!

 

I am using the find command to find files with a certain extension, and gzip them, like this:

find . -name '*.xml' -mtime +05 -exec gzip {}  \;

 but everytime it finds a file that is already compressed, produces the following output:

gzip:./BCH43273/SEQ0/BAL_TX5187.42135.xml.gz already exists; do you wish to overwrite (y or n)?

 How skip or avoid this ?

 

 

P.S. This thread has been moevd from HP-UX > System Administration to HP-UX > languages. - Hp Forum Moderator

7 REPLIES 7
Dennis Handly
Acclaimed Contributor

Re: the use of find command

>every time it finds a file that is already compressed, produces the following output:

 

I can't see how that happens unless you have a directory ending in .xml?

Add "-type f" to your find.

NDO
Super Advisor

Re: the use of find command

Hi!

 

the -type -f did not work.... I do not have a dir ending with .xml... is just files

Patrick Wallek
Honored Contributor

Re: the use of find command

My guess is that you are finding a file named BAL_TX5187.42135.xml when your find is running.  As a result of finding that file, gzip is running to compress.  However, there is already a file named BAL_TX5187.42135.xml.gz so gzip is asking if you wish to overwrite what is already there.

 

 

Dennis Handly
Acclaimed Contributor

Re: the use of find command

>there is already a file named BAL_TX5187.42135.xml.gz

 

Because the last run aborted?

Looking at the times of the two files may help:

ll ./BCH43273/SEQ0/BAL_TX5187.42135.xml*

NDO
Super Advisor

Re: the use of find command

yes the idea is for gzip not to ask just skip
NDO
Super Advisor

Re: the use of find command

yes  there is :

ll ./BCH43273/SEQ0/BAL_TX5187.42135.xml*
-rw-rw-rw-   1 bscsprod   bscs          1666 Dec 15 21:15 ./BCH43273/SEQ0/BAL_TX5187.42135.xml
-rw-r--r--   1 bscsprod   bscs           340 Sep 12  2013 ./BCH43273/SEQ0/BAL_TX5187.42135.xml.gz

 

Patrick Wallek
Honored Contributor

Re: the use of find command

So you definitely have duplicate names.  The .gz file from Sep. 12, 2013 and the regular file from Dec. 15, 2013, hence the question.

 

You cannot tell gzip to just skip the file.

 

The only option is to use 'gzip -f' which will overwrite the existin .gz file with the new one.

 

# gzip -?

gzip 1.3.5 (HP-UX fixlevel 1)
(2002-09-30)
usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
-c --stdout write on standard output, keep original files unchanged
-d --decompress decompress
-f --force force overwrite of output file and compress links
-h --help give this help
-l --list list compressed file contents
-L --license display software license
-n --no-name do not save or restore the original name and time stamp
-N --name save or restore the original name and time stamp
-q --quiet suppress all warnings
-r --recursive operate recursively on directories
-S .suf --suffix .suf use suffix .suf on compressed files
-t --test test compressed file integrity
-v --verbose verbose mode
-V --version display version number
-1 --fast compress faster
-9 --best compress better
file... files to (de)compress. If none given, use standard input.
Report bugs to <bug-gzip@gnu.org>.