Re: the use of find command (96 Views)
Reply
Super Advisor
NDO
Posts: 531
Registered: ‎12-10-2003
Message 1 of 8 (171 Views)

the use of find command

[ Edited ]

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,745
Registered: ‎03-06-2006
Message 2 of 8 (157 Views)

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.

Please use plain text.
Super Advisor
NDO
Posts: 531
Registered: ‎12-10-2003
Message 3 of 8 (126 Views)

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

Please use plain text.
Honored Contributor
Patrick Wallek
Posts: 13,714
Registered: ‎06-21-2000
Message 4 of 8 (122 Views)

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.

 

 

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,745
Registered: ‎03-06-2006
Message 5 of 8 (113 Views)

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*

Please use plain text.
Super Advisor
NDO
Posts: 531
Registered: ‎12-10-2003
Message 6 of 8 (102 Views)

Re: the use of find command

yes the idea is for gzip not to ask just skip
Please use plain text.
Super Advisor
NDO
Posts: 531
Registered: ‎12-10-2003
Message 7 of 8 (102 Views)

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

 

Please use plain text.
Honored Contributor
Patrick Wallek
Posts: 13,714
Registered: ‎06-21-2000
Message 8 of 8 (96 Views)

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>.

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation