Hi,
I want to search for a particular string using awk and print "Found" or "Not Found" depending on the search.
On searching this forum i got this code but it is not working:
Hi,
I want to search for a particular string using awk and print "Found" or "Not Found" depending on the search.
On searching this forum i got this code but it is not working:
Something like this?
awk '/Reference_Data/{f=1;exit}END{print f?"Found":"Not Found"}' file
Can you try as..
awk '{print $0~/Reference_Data/?"Found":"Not Found"}' file
or
awk '{print /Reference_Data/?"Found":"Not Found"}' file # not sure if this would work
declare -i toggle=0
while read -r line
do
case "$line" in
*Reference_Data*) toggle=1;;
esac
done < file
if [ $toggle -eq 0 ] ;then
echo "Not found"
else
echo "Found"
fi
thanks for replies, but i am still getting same error.
Use nawk or /usr/xpg4/bin/awk on Solaris.
Thanks.. now working fine..