about ksh ? /// for LINVIN FREE

(ps -ef | grep [p]rocessname >/dev/null 2>&1) \
&& echo "OK" \
|| echo "Not OK"

Thank you very much for your answer.
what is the effect of " >/dev/null 2>&1 "
I don't understand 2>&1

I'm just junior in programming Unix.
:wink:

No problem :slight_smile:

The ">" sends output to wherever you want.
/dev/null is no-man's land. Anything going into the null device is removed. I use it a lot for this application: >/dev/null basically nulls out all output on stdout (the standard output mechanism).
What 2>&1 does, is send stderr (standard error) into stdout (standard output).
The numbers are actually "file descriptors"; 0 is input, 1 is standard out, and 2 is standard error.

So for example, you don't want to see any output, but you want to log error to a file, you could do:
./program >/dev/null 2>/tmp/my_log
A very common one I use is:
find /dir -name blah -type f >/dev/null
So when I get error about Permission Denied when trying to search a large amount of directories, it doesn't fill my screen - I just get the normal output without errors.

I don't know if I explained this very well... Can anyone else explain this better for me?

thank you LIVIN FREE
Your answer helps me much.