我正在使用grep -c来计数在curl上一个短语的出现。当前,下面的代码返回数字12。
curl WEBSITEURL | grep -c "incident-title"
Run Code Online (Sandbox Code Playgroud)
我想在if / else bash命令的单行中使用此命令,该命令说如果出现的次数大于0,则为printf,否则为printf。
if curl WEBSITEURL | grep -c "incident-title" > 0; then printf "Investigating Issue"; else printf "Fully Operational"; fi
Run Code Online (Sandbox Code Playgroud)
它会继续返回“完全运行”状态,即使12为大于0时也应为true。
预先感谢您的协助。