echo statement when find returns null

Hi,

How do you echo something once when a find statement returns null results?

This is when using mutiple locations and mutiple arguments.

The below find command the inner loop of a nested for loop where the outter loop holds the $args and the inner loop holds the locations.

find $location -name $args

Want the statement to print 'no such file' for the $args when all locations have been searched and not found a matching file in any of the locations. But just print the location and nothing else if the arg is found in any of the locations.

Sorry if this has been asked before I've searched and not found anything.

you can redirect the 'find...-print' output to a file

find ... -print > file.out

and then call word count (lines only) into a variable.

COUNT=`wc -l file.out`

then eval $COUNT and output your error when = 0, or the contents of file.out when >0.

hth,
dv

Thanks varontron ended up using the above logic to get the results i wanted though it took a while :slight_smile: