我正在尝试运行一些shell命令,如果一个字符串不存在于文本文件中。如果我将这行代码粘贴到命令行中,它会给我一个错误。
if [ $(cat textfile.txt | grep "search string") -eq "" ]; then; echo "some string"; fi;
错误:
-bash: [: -eq: unary operator expected