括号在简单的bash行中丢失错误? [英] Bracket missing error in simple bash line?
本文介绍了括号在简单的bash行中丢失错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的bash脚本中的以下两行:
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 $out_file | grep "$fail_str" ] ; then
给出错误:
./joi_main.sh: line 63: [: missing `]'
grep: ]: No such file or directory
他们怎么了?
推荐答案
丢掉[]
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)
您可能还想使grep
s静音:
you may also then want to silence the grep
s:
if tail -1 /home/pi/video_buffer_usage.txt | grep -q '100% full' ||
tail -2 "$out_file" | grep -q "$fail_str" ; then
这篇关于括号在简单的bash行中丢失错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文