Script: Global Search for a string and Report

#!/bin/sh

#set -x

N=`basename $0`

if [ $#  -ne 2 ]

then

echo “$N: Usage”

echo ”        $N <Search Path> <Search String>“

exit 0

fi

dir_path=$1; str_search=$2;

for file in $(find $dir_path -type f  2>/dev/null)

do

grep -i     $str_search     $file    2>/dev/null >/dev/null

if [ “$?” -eq “0” ]

then

echo  “$file”  >>/tmp/search_ravi$$

fi

done
****

Thanks,
Ravi

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: