This is GREAT for use in scripts. If the string you're grepping for gets a match, it returns 0.
No fiddling with comparison operators for your if statements!
#!/bin/sh
if grep -q needle haystack.txt
then
echo "I found a needle!"
else
echo "No needles here..."
fi
No comments:
Post a Comment