Hi guys I have this problem... I am supposed to Check if the word i had input, exist in the txt.file
And i am having a problem with my codes...
cat File.txt | while read TEXT
if [ grep $input $TEXT -eq 0]
echo "Found"
else
echo "Not found!"
fi
Hi guys I have this problem... I am supposed to Check if the word i had input, exist in the txt.file
And i am having a problem with my codes...
cat File.txt | while read TEXT
if [ grep $input $TEXT -eq 0]
echo "Found"
else
echo "Not found!"
fi
if condition
then
do something
else
do something
fi
awk '/<word>/ {i++};END{if(i){print "Found"}else{print "Not Found"}}' filename
grep look from file. Exit status is 0 if founded and not 0, if not. Output of grep is not interesting.
if grep "$input" File.txt >/dev/null 2>&1
then
echo "Found"
else
echo "Not found!"
fi
If you like to use while, then ex.
while read line
do
data=${line/$input/}
[ "$data" != "$line" ] && echo "found" && exit 0
done < File.txt
echo "not found"
exit 1