#! bin/bash
#To find/check for any string in any specific column:
echo "enter a filename to print from awk"
read fileName
if [[ -f $fileName ]]
then
awk ' { if($NF == "2000") print $0;} ' $fileName
echo "==============================================================="
awk ' { if($3== "MAC") print $0;} ' $fileName
echo "==============================================================="
awk ' { if($2== "MAC") print $0;} ' $fileName
echo "==============================================================="
else
echo "$fileName doesn't exist"
fi
[prabhucloudxlab@cxln4 ~]$ sh hello.sh
enter a filename to print from awk
filegrep.txt
This is Linux 2000
This is Linux 2000
This is Linux 2000
This is Linux 2000
===============================================================
This is MAC 4000
This is MAC 4000
This is MAC 4000
This is MAC 4000
===============================================================
===============================================================