Bracket missing error in simple bash line?

前端 未结 2 2036
清酒与你
清酒与你 2021-01-29 03:11

The following 2 lines in my bash script:

fail_str=$\'Checking...\\nChecking...\'
if [ tail -1 /home/pi/video_buffer_usage.txt | grep \'100% full\' ] || [ tail -2         


        
2条回答
  •  遥遥无期
    2021-01-29 03:52

    lose the []s:

    if tail -1 /home/pi/video_buffer_usage.txt | grep '100% full' ||
      tail -2 "$out_file" | grep "$fail_str" ; then
    

    (added harmless newline for readability)

    you may also then want to silence the greps:

    if tail -1 /home/pi/video_buffer_usage.txt | grep -q '100% full' ||
      tail -2 "$out_file" | grep -q "$fail_str" ; then
    

提交回复
热议问题