Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix find with size dosen't work

Status
Not open for further replies.
Jun 21, 2006
6
US
Hi
I am having the following find commnand to find logfiles which are greater than 100k in size and list them

find /oracle \( -name "*.log" -a ! -name "alert_*" \) -o -name "*.trc" -o -name "*.trw" -o -name "core.*" -type f -size +100k | xargs ls -l .

The output from the command contains files which are less than 100k.
Since this is a complex expression are we facing this issue ? Any workarounds ?
Regards
Upilli
 
What OS? From the AIX man page:

-size n Evaluates to the value True if the file is the specified n of blocks long (512 bytes per block). The file size is rounded up to the nearest block for
comparison.

-size nc Evaluates to the value True if the file is exactly the specified n of bytes long. Adding c to the end of the n variable indicates that the size of the
file is measured in individual bytes not blocks.

the k option seems unusual to me.
 
Needs more brackets I assume:

for instance your -o "*.trc" lists trc files regardless of the size limit.

Also leave out the dot on the xargs ls -l


find \( \( /oracle -name "*.log" -a ! -name "alert_*" \) -o \( -name "*.trc" -o -name "*.trw" -o -name "core.*" \) \) -type f -size +100k | xargs ls -l

or use the -exec clause:

find \( \( /oracle -name "*.log" -a ! -name "alert_*" \) -o \( -name "*.trc" -o -name "*.trw" -o -name "core.*" \) \) -type f -size +100k -exec ls -l {} \;

(both untested)



HTH,

p5wizard
 
It's not always available Ken. And annoyingly on Solaris 8, for example, if you specify 'k' or any character other than 'c' it silently ignores it and uses the default of blocks.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top