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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make it one liner pls

Status
Not open for further replies.

hok1man

Technical User
Feb 16, 2008
102
Hi Guys,

as title aboved, the original command is :
ps -ef | nawk '$1=="napln"{print $0}' | grep -i /data | grep -i $JOB

I'm using Solaris 8

Thanks guys.
 
For starters, {print $0} is unnecessary, as that is the default action, so you could write:

[tt]ps -ef | nawk '$1=="napln"' | grep -i /data | grep -i $JOB[/tt]

But you don't need awk to do that part anyway, since it's built in to ps:

[tt]ps -fu napln | grep -i /data | grep -i $JOB[/tt]

Also you can combine the greps if you know the order the strings are likely to be in, e.g.

[tt]ps -fu napln | grep -i /data.*$JOB[/tt]

...where .* matches any characters between the two search strings.

If you wish to use awk, unfortunately it doesn't have a very convenient way to do case-insensitive searches. But you could do something like this:

[tt]ps -ef | awk -v job=$JOB '$1=="napln" && tolower($0) ~ /\/data/ && toupper($0) ~ tolower(job)'[/tt]

Annihilannic.
 
Hi Anni,

thanks for explanation..
is there any simplified command for this :
ps -aux nawk '$1=="napln"'

Because I need to see the full command process.
thanks,
 
auxwwww are BSD-style ps options, you shouldn't really precede them with a -. Unfortunately with BSD options there is no built-in filter by user name, so that is probably the simplest syntax you could use.

On Linux you can actually mix BSD and UNIX style options, although it's probably not very good practice. I often use ps www -ef for example to get wide output like you describe, so you could use ps u napln. Just don't tell anyone I said you could. :p

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top