|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hey all,
I'm looking for some with awk. Our Midrange (unix) team just upgraded our lpar from aix 5.1 to 5.2ML6 Since the upgrade my awk -v option has stopped working. The syntax below will find the literal value "M" in the ps list, not the contents of variable $CS. for CS in R1 R3 A1 A3 do CSPID=`ps -ef|awk -v M=$CS '/M/ && /exec/ && !/awk/ {print $2}'` Have I been getting away with incorrect syntax all along or is there really a bug? Any insight would be ful. Thanks, Roger |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Noatec wrote:
> Hey all, > I'm looking for some with awk. > Our Midrange (unix) team just upgraded our lpar from aix 5.1 to 5.2ML6 > Since the upgrade my awk -v option has stopped working. > > The syntax below will find the literal value "M" in the ps list, not > the contents of variable $CS. > > for CS in R1 R3 A1 A3 > do > CSPID=`ps -ef|awk -v M=$CS '/M/ && /exec/ && !/awk/ {print $2}'` > > Have I been getting away with incorrect syntax all along or is there > really a bug? Your syntax is wrong. The above would search for the character "M" not the value of the variable "M". What you want is: awk -v M="$CS" '($0 ~ M) && /exec/ && !/awk/ {print $2}' Ed. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Noatec <Noatec@gmail.com> wrote:
> Hey all, > I'm looking for some with awk. > Our Midrange (unix) team just upgraded our lpar from aix 5.1 to 5.2ML6 > Since the upgrade my awk -v option has stopped working. > > The syntax below will find the literal value "M" in the ps list, not > the contents of variable $CS. > > for CS in R1 R3 A1 A3 > do > CSPID=`ps -ef|awk -v M=$CS '/M/ && /exec/ && !/awk/ {print $2}'` > > Have I been getting away with incorrect syntax all along or is there > really a bug? Most likely. The right syntax would more look like: $(ps -ef | awk -v M=$CS 'match($0, X) && /exe/ && !/awk/ { print $2}') -- Daniel |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Both examples worked perfectly !!
Thanks Guys. I know it doesn't make it right, but my syntax did work in AIX 5.1 |
|
![]() |
| Outils de la discussion | |
|
|