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