Bash Script using Grep to search for a pattern in a file
Posted
by atif089
on Stack Overflow
See other posts from Stack Overflow
or by atif089
Published on 2010-06-16T11:38:07Z
Indexed on
2010/06/16
11:42 UTC
Read the original article
Hit count: 260
I am writing a bash script to search for a pattern in a file using GREP. I am clueless for why it isnt working. This is the program
echo "Enter file name...";
read fname;
echo "Enter the search pattern";
read pattern
if [ -f $fname ]; then
result=`grep -i '$pattern' $fname`
echo $result;
fi
Or is there different approach to do this ?
Thanks
© Stack Overflow or respective owner