Prevent grep returning an error when input doesn't match

后端 未结 6 2323
鱼传尺愫
鱼传尺愫 2020-12-08 04:01

I want to write in a bash script a piece of code that checks if a program is already running. I have the following in order to search whether bar is running

         


        
6条回答
  •  -上瘾入骨i
    2020-12-08 04:11

    Try to make so:

    ps auxw | grep -v grep | cat

    cat returns always 0 and ignores exit code of grep

提交回复
热议问题