|
Prev: what is the meaning of IFS ???
Next: list of Dirs
From: Smith on 18 Jun 2006 01:32 Hi, I'm trying to grep a PID (eg 1234) currently i'm ps -ef grep 1234 |awk '{print $2}' |wc to make sure that i'm grepping the exact 1234 (4 digit PID) and not 12345. Is there more elagant and efficient way of grepping the PID, 1234? Thanks and regards
From: Xicheng Jia on 18 Jun 2006 01:38 Smith wrote: > Hi, > I'm trying to grep a PID (eg 1234) > currently i'm ps -ef grep 1234 |awk '{print $2}' |wc to make sure that i'm > grepping the exact 1234 (4 digit PID) and not 12345. > > Is there more elagant and efficient way of grepping the PID, 1234? no need to use grep, use awk directly: ps -ef | awk '$2==24' Xicheng
From: Xicheng Jia on 18 Jun 2006 01:42 Xicheng Jia wrote: > Smith wrote: > > Hi, > > I'm trying to grep a PID (eg 1234) > > currently i'm ps -ef grep 1234 |awk '{print $2}' |wc to make sure that i'm > > grepping the exact 1234 (4 digit PID) and not 12345. > > > > Is there more elagant and efficient way of grepping the PID, 1234? > > no need to use grep, use awk directly: > > ps -ef | awk '$2==24' my bad, I was testing PID==24 in my own machine, and forgot to change it back to 1234 to suit your case when pasting. :( ps -ef | awk '$2==1234' Xicheng
From: Smith on 18 Jun 2006 02:20 XiCheng, Thanks, now worry about the mistake, I understand that 24 is the PID you use for your testing hahaha "Xicheng Jia" <xicheng(a)gmail.com> wrote in message news:1150609333.551432.270560(a)i40g2000cwc.googlegroups.com... > Xicheng Jia wrote: >> Smith wrote: >> > Hi, >> > I'm trying to grep a PID (eg 1234) >> > currently i'm ps -ef grep 1234 |awk '{print $2}' |wc to make sure that >> > i'm >> > grepping the exact 1234 (4 digit PID) and not 12345. >> > >> > Is there more elagant and efficient way of grepping the PID, 1234? >> >> no need to use grep, use awk directly: >> >> ps -ef | awk '$2==24' > > my bad, I was testing PID==24 in my own machine, and forgot to change > it back to 1234 to suit your case when pasting. :( > > ps -ef | awk '$2==1234' > > Xicheng >
From: kenneth kahn on 18 Jun 2006 06:24
> "Xicheng Jia" <xicheng(a)gmail.com> wrote in message > ps -ef | awk '$2==1234' Just for my education, is there any difference between your example and the following: ps -e | awk '$1==1234' Would either way be correct; if not why not? |