Grep : Script for case sensitive & For Line Numbers & count of lines which is not contains the given text(-v)

 

[prabhucloudxlab@cxln4 ~]$ cat>hello.sh

#! bin/bash
# Script for case sensitive & For Line Numbers & For Count

echo " enter filename is search text from "
read filename
if [[ -f $filename ]]
then
echo "enter the text1 to search"
read grepvar1
grep -i -n -c -v $grepvar1 $filename
#note: -v ---->> will give the count of lines which is not contains the given text
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
windows
17

============================================================
Note:
: '
#! bin/bash
# Script for case sensitive & For Line Numbers & For Count
echo " enter filename is search text from "
read filename
if [[ -f $filename ]]
then
echo "enter the text1 to search"
read grepvar1
grep -i -v $grepvar1 $filename
#note: -v ---->> will give the count of lines which is not contains the given text
else
echo "$filename does not exist"
fi



Output: 
windows
This is linux
This is MAC
This is linux
This is MAC
This is linux
This is MAC
This is linux
This is MAC
This is linux
This is MAC
This is linux
This is MAC
This is linux
This is MAC
This is linux
This is MAC
'