LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shell script to read ps -e output and determine process double processes. (https://www.linuxquestions.org/questions/programming-9/shell-script-to-read-ps-e-output-and-determine-process-double-processes-365693/)

dr_zayus69 09-21-2005 03:41 PM

shell script to read ps -e output and determine process double processes.
 
hi. I just noticed doing ps -e that there was three instances of mplayer running. I am thinking of making a script to search the output of pe -e and determine if there are multiples of a program running. i am not sure as to how i can go about storing the output in a variable to make it easy to test against. Can anyone steer me in the right direction? thanks for your replies in advance.

bhar0761 09-21-2005 05:37 PM

simple approach would be to grep the results in a count based on line and run test on it

ps -e | grep mplayer | wc -l


store as variable and run test on it like

i=$(ps -e | grep mplayer | wc l)
if [ i -gt 1 ]
then
do
don


All times are GMT -5. The time now is 03:27 AM.