Grep : Script for case sensitive & For Line Numbers (-n)

 

[prabhucloudxlab@cxln4 ~]$ cat>hello.sh
#! bin/bash
# Script for case sensitive & For Line Numbers

echo " enter filename is search text from "
read filename
if [[ -f $filename ]]
then
echo "enter the text1 to search"
read grepvar1
grep -i -n $grepvar1 $filename

else
echo "$filename does not exist"
fi


[prabhucloudxlab@cxln4 ~]$ sh hello.sh
 enter filename is search text from
filegrep.txt

enter the text1 to search
linux

1:This is linux
4:This is linux
8:This is linux
11:This is linux
14:This is linux
17:This is linux
20:This is linux
23:This is linux