2017-11-21 5 views
0

grep 명령의 결과를 변수에 저장하려고합니다. GREP (grep -fxq) 명령의 출력과 함께 할당 된 변수가 비어 있습니다.

은 다음과 같은 내용 ::로 파일 chkk.txt을 만든

ABC DVF GHI RFG

tmp=$(grep -c "abc" /tmp/chkk.txt) 
echo $tmp 
1 

그러나 그렙이 fxq 인수를 사용하는 경우, 변수 'TMP는'비어

tmp=$(grep -Fxq "abc" /tmp/chkk.txt) 
echo $tmp 

-fxq 인수가있는 GREP가이 경우 작동하지 않는 이유에 대해 알고 싶습니다.

답변

2

남자 그렙 :

-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.