Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-21-2005, 04:41 PM   #1
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Rep: Reputation: 35
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.
Old 09-21-2005, 06:37 PM   #2
Registered: Jul 2005
Location: San Francisco
Distribution: Fedora Core 6
Posts: 64

Rep: Reputation: 15
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 ]


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
executing shell script in terminal directly with a double click kushalkoolwal Programming 15 11-26-2012 03:32 PM
how to execute a shell script in GUI by double click kamesh156 Programming 1 10-18-2005 06:25 AM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 06:39 AM
Redirecting process output to shell mhelles Linux - Newbie 1 04-30-2003 10:30 AM
How to determine whether a PROCESS is running, by a SHELL program? yuzuohong Linux - General 4 01-21-2003 09:41 PM

All times are GMT -5. The time now is 07:39 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration