I am trying to generate a list of PID's to pass to strace I only want the PID's php-fpm. I can get the correct output by using grep with awk but am looking for an awk only answer. Here is what I have done.
This gives the desired output:
$ ps ajxf |grep '[p]hp-fpm: pool' |awk '{print $2}'
21547
21548
21549
21938
31131
31132
31133
31189
36283
10549
12179
12893
12964
12989
13565
14420
14421
15848
17737
This one did not:
$ ps ajxf |awk '/php-fpm: pool/{if (NR!=1) {print $2}}'
22903 <--- This is the PID of the awk
21547
21548
21549
21938
31131
31132
31133
31189
36283
10549
12179
20328
20392
20393
20618
22006
22793
22794
22804