LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-20-2012, 01:04 AM   #1
student23
LQ Newbie
 
Registered: Jan 2012
Posts: 21

Rep: Reputation: Disabled
Unhappy How to list processes or services that begin with a specific letter


Hello everyone,

I would like to list all processes or services that start with the letter s. I have tried running the command service --status-all | grep s* and also the ps command with the same syntax but no success. Thank you in advance for your responses.
 
Old 01-20-2012, 01:22 AM   #2
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by student23 View Post
service --status-all | grep s*
* is a globbing character. Because you did not protect it from the shell by quoting it appropriately, the shell expands it. The pattern s* will be expanded into the list of files in the current working directory who's names begin with s.

grep processes regular expressions. Your regular expression, had you quoted it to protect it from the shell, would match every line with zero or more instances of the character s. In other words, every line.

HTH

Last edited by Telengard; 01-20-2012 at 01:27 AM. Reason: insert the correct link
 
Old 01-20-2012, 02:34 AM   #3
student23
LQ Newbie
 
Registered: Jan 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
I'm making an effort on trying to understand what you said by reading the information on the links but I'm not grasping it. Thank your for your response.
 
Old 01-20-2012, 02:45 AM   #4
barunparichha
Member
 
Registered: Jun 2006
Location: Bangalore,india
Distribution: Linux(Redhat,fedora,suse,ubantu), Solaris (s8/s9/s10/nevada/open-solaris)
Posts: 303

Rep: Reputation: 32
Try them :

Code:
ps -eaf | grep ^s


or


service --status-all | grep ^s
 
Old 01-20-2012, 03:08 AM   #5
rainbowsally
Member
 
Registered: Oct 2011
Posts: 47
Blog Entries: 138

Rep: Reputation: Disabled
Quote:
Originally Posted by student23 View Post
Hello everyone,

I would like to list all processes or services that start with the letter s. I have tried running the command service --status-all | grep s* and also the ps command with the same syntax but no success. Thank you in advance for your responses.
Also try 'pgrep <substring>'

You can further limit the output with 'pgrep <substring> -u <user>' also.

This will give you a list of pids which you can use to look up app names (using readlink) in /proc/<pid>/exe links.

These 'exe' links always return the actual running file with the full path.

So there are several options here.

Great question! And great answers!
 
  


Reply



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
How to correlate ata<number> in dmesg to specific /dev/sd<letter>? bgoodr Linux - Hardware 17 11-28-2010 01:56 PM
[SOLVED] Change to capital first letter of every word over specific column cgcamal Programming 10 05-02-2010 07:22 AM
adding proc list and task list of active processes. pravin.embedded Linux - Newbie 1 09-02-2008 01:20 PM
Delete specific lines of a file beginning with a certain letter docaia Programming 4 08-24-2008 11:04 PM
Assign a specific drive letter to a network location in crossover office? blo81 Linux - Newbie 2 05-22-2007 08:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:56 PM.

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