multiple -name in find

Hi,

Can I have multiple -name options when using find?

I am using -> find . \( ! -name . -prune \) because I only want to search in the directory i'm in, not sub dirs. But i wan the specify the files I do search for.

How can I do this?

It is in part of this string
for file in `find . \( ! -name . -prune \) \
-user cgi \
-mtime +$age \
-exec basename {} \;`

Cheers in advance,

Here is an example:

cd /etc
find . \( ! -name . -prune \) \( -name \*passwd\* -o -name \*shadow\* \) -print

Hi Perderabo

This is great, I managed it to do what I was wanting from the command line but when I tried to put it into my script I was getting no files returned.

I have taken the liberty to include my script, would you mind checking it over?

Many thanks in advance

HP_UX 11i

#! /bin/ksh

control=/home/nhatch/CLEAN/clean_cntrl
dates=`date +%d%m%y_%H%M%S`
rmlog=/home/nhatch/CLEAN/removed_$dates.log

echo "Running $0" >> $rmlog
while read line
do
{
        dir=`echo $line | cut -d, -f1`
        age=`echo $line | cut -d, -f2`
        ext=`echo $line | cut -d, -f3`

                echo  "\t Current search dir is $dir" >> $rmlog
                echo $age
                echo $ext

        for file in `find $dir \( ! -name . -prune \) \( -name \*.$ext \) \
                -user cgi \
                -mtime +$age \
                -exec basename {} \;`
        do
        rm $file
        if [ $? -eq 0 ]
        then
                echo "File $file was deleted " >> $rmlog
        else
                echo "File $file was NOT deleted"  >> $rmlog
        fi
        done

}
done < $control

the control file is listed as example, directory/age/extension

/home/nhatch,5,DAT
/home/admin,7,tmp

Don't use "find $dir" with the -prune trick. You must "cd $dir", then "find .". As it is, you're pruning everything.

many thanks. Works fine now.

Have a good day :smiley: