The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ps avg | grep ? filter the desired out put. varungupta UNIX for Advanced & Expert Users 1 04-10-2009 05:30 PM
Grep script to filter kevin9 Shell Programming and Scripting 2 02-21-2009 01:59 AM
how to filter `last` command for yesterday only skully Shell Programming and Scripting 1 06-26-2008 05:30 AM
grep a log file to filter previous dates pinpe Shell Programming and Scripting 5 08-03-2007 02:25 PM
Filter results through pipe with grep ckandreou UNIX for Dummies Questions & Answers 1 07-10-2006 03:04 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-23-2009
LRoberts LRoberts is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 87
filter grep command

I have ran into a small issue and I am not sure how to fix it.
In one of our current scripts we have this line which does a grep to get the pid of the process.


Code:
ps -ef | grep nco_p_syslog | grep $x | awk '{print $2}'

However this is not returning anything due to the how long the value of $x is. Which a sample value is...


Code:
ot1p_stdby

However as you can see a simple grep cuts this off...

Code:
tivoli 20343     1   0 10:16:09 pts/1       0:00 /lcl/apps/Tivoli/netcool/omnibus/probes/solaris2/nco_p_syslog -manager ot1p_std

I need to find a way to do a grep command like below only have it know off the _stdby contained within $x.
So that even though $x contains the value ot1p_stdby it should cutt off the _stdby and only by ot1p when it does the following command.,,,


Code:
ps -ef | grep nco_p_syslog | grep $x | awk '{print $2}'

I was not sure if there is a way to do this right in the command above.

Thanks
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0