我想像这样在bash中比较两个命令的结果:
if `cat /root/pid` == `ps aux | grep "python" | grep -v grep | awk '{print $2}'`
then
<SomeCommands>
else
<OtherCommands>
fi
我想检查cat /root/pid
和的结果ps aux | grep "python" | grep -v grep | awk '{print $2}'
是否相等。
我还想检查特定command
服务器上是否正在运行特定服务器。我认为这种方法有效。任何其他方法都可以使用。
谢谢
您可以使用:
[[ "$(cat /root/pid)" == "$(ps aux | grep 'python' | grep -v grep | awk '{print $2}')" ]]
尽管我相信您可以减少这两项工作,grep
并且自己使用所有功能awk
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句