I want to print zero if grep is not found in a particular filegrep -A4  Apple  a.txt | tail -1 | awk '{printf(%f, $4)}' >> outI tried using if else condition tooif grep -A4  Apple  a.txt | tail -1 ;then     awk '{printf(%f, $4)}' >> outelse     echo 0 >> outfiSo, for example, given this file:Appleis xyz abc def cost 352.271My command greps for apple and prints 352.271. But if there's no match, I want it to print 0.
Print zero if text is not found in a particular file
shell script;grep