find filenames like unix commands

Hi,

I need to write a small script to search in some specific directories to check if any file is present with a unix command name...
Means if the directory contains any files like cat, vi, grep, find etc i need to list those files into a file.

Please help
Thanks,
D

u can have a shell script like "search.sh" which accepts a directory name as an argument..

search.sh may look like

#! /bin/sh
DIR_NAME =$1
# u have to search for all the unix files one by one like and write to serach.log file. Below command will do the same for you
#find DIR_NAME name nameoffile > search.log
find DIR_NAME name cat > search.log
find DIR_NAME name grep > search.log

I am also new to linux.. this solution will work but only thing is the script will be as long as set of unix commands u want to find out.

Cheers!!

is there any option in find command for the purpose like:

find . -name "cat" -print

will print only the files named like cat.. if we can add multiple patterns in the place of cat , thats what i need.

find . -type f | grep -E "cat|vi|grep"

Add further patterns by separating them with a pipe.

If your version of find supports the -regexp flag, you can do

find dir -type f -regexp ".*\(cat\|vi\|grep\)"

Otherwise

find dir -type f -name cat -o -name vi -o -name grep

Thanks buddies

find . -type f | grep -E "cat|vi|grep"

will get any files matching the pattern. Therefore if there is a file like "catert"
or "vides" they will also match cat and vi pattern and I want the exact pattern. I tried grep -Ex but not working.

There fore

find dir -type f -name cat -o -name vi -o -name grep

is the one which can be used I believe though it will become lengthier

By using anchor and brackets in regular expression, you can achieve the same effect

$ DIRNAME=/usr/bin
$ find $DIRNAME -type f | egrep "^$DIRNAME/(cat|vi|grep)$"