2017-11-21 3 views
0

grepコマンドの結果を変数に格納しようとしています。次の内容のファイルchkk.txtを作成しGREP(grep -fxq)コマンドの出力に変数が割り当てられています

::

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 

この場合、-fxq引数でGREPが機能しない理由を理解したいと思いますか?

答えて

2

男の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. 
関連する問題