我试图将grep命令的结果存储到变量中。
使用以下内容::
创建了一个chkk.txt文件abc dvf ghi rfg
tmp=$(grep -c "abc" /tmp/chkk.txt)
echo $tmp
1
但是当grep与fxq参数一起使用时,变量' tmp'为空
tmp=$(grep -Fxq "abc" /tmp/chkk.txt)
echo $tmp
我想了解为什么GREP与-fxq参数在这种情况下不起作用的原因?
答案 0 :(得分:2)
man grep:
-q, --quiet, --silent
Quiet; do not write anything to standard output. Exit
immediately with zero status if any match is found, even if an
error was detected. Also see the -s or --no-messages option.