mercredi 14 janvier 2015

How do I make an output for grep fail?


I am using if-else statement to search for keywords and displaying the results in the terminal, here's an example of my code.



read finding

if ["$finding" != "" ]; then
grep $finding information.txt
else
echo "No such information in database."
fi


But the terminal does not display anything if i key in information that does not exist. I started shell about a week back, might need more explanation on how certain code works.



Aucun commentaire:

Enregistrer un commentaire