Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Process ID Only

Status
Not open for further replies.

bopritchard

Programmer
Joined
Jan 27, 2003
Messages
199
Location
US
I want to locate a process by name and return it's Process ID ONLY...

i've been doing ps -ef|grep smr|grep -v grep

but that gives me the whole line...all i want returned is the ID
 
Try piping the result to awk:

ps -ef | grep smr | grep -v grep | awk '{print $2}'

This will take field 2 of the result. The default field separator for awk is white space. This is just the tip of the iceberg for what awk can do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top