if grep -Fxq $name1 test.txt
这似乎不起作用。有什么建议吗?
你可以这样做:
match=`grep $name1 test.txt`
if [ -n "$match" ]; then
echo found
fi
你可以试试这个:
grep -Fxq $name1 test.txt
if [ $? -eq 0 ]; then
... test.txt contains $name1 ...
else
... test.txt does not contain $name1 ...
fi
就足够了:
grep $name1 test.txt