小编New*_*nds的帖子

在if语句中使用grep

我是shell脚本的初学者,需要一个脚本来检查一个进程的状态,并在输出时"输出","关闭时"输出"不运行".

我尝试了下面的一个,但它不起作用:

if [ -s `/opt/reds/recycle.sh status | grep "pid"` ];
then
    echo "running"
else
    echo "not running"
fi
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?

shell grep if-statement

2
推荐指数
1
解决办法
154
查看次数

标签 统计

grep ×1

if-statement ×1

shell ×1