Hi.
Thanks for taking a look.
1) have added code brackets
2) I'm just doing this for learning purposes. I'm running a bash shell in windows, there Is only 1 bash process running. If I just run the command:
Code:
ps ax | grep [b]ash | awk '{print $1}';
output is always the same:
Code:
root@WLCYLTP02:~/learning/sed/mine# ps ax | grep [b]ash | awk '{ print $1 }';
2
root@WLCYLTP02:~/learning/sed/mine# ps ax | grep [b]ash | awk '{ print $1 }';
2
root@WLCYLTP02:~/learning/sed/mine# ps ax | grep [b]ash | awk '{ print $1 }';
2
root@WLCYLTP02:~/learning/sed/mine# ps ax | grep [b]ash | awk '{ print $1 }';
2
root@WLCYLTP02:~/learning/sed/mine# ps ax | grep [b]ash | awk '{ print $1 }';
2
3)
Tried with:
Code:
ps ax | awk '/bash/ { print $1 }'
Code:
root@WLCYLTP02:~/learning/sed/mine# ps ax | awk '/bash/ { print $1 }'
2
199
root@WLCYLTP02:~/learning/sed/mine# ps ax | awk '/bash/ { print $1 }'
2
201
root@WLCYLTP02:~/learning/sed/mine# ps ax | awk '/bash/ { print $1 }'
2
203
Checking the above, it appears when i save as variable, i'm saving the awk PID also.
Code:
root@WLCYLTP02:~/learning/sed/mine# ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 /init
2 tty1 Ss 0:01 /bin/bash
204 tty1 R 0:00 ps ax
i was using [b]ash so the grep process doesn't appear as it wont search for [b]ash , only wanted the single bash process
Code:
root@WLCYLTP02:~/learning/sed/mine# ps ax | grep [b]ash ;
2 tty1 Ss 0:01 /bin/bash
root@WLCYLTP02:~/learning/sed/mine# ps ax | grep bash ;
2 tty1 Ss 0:01 /bin/bash
224 tty1 S 0:00 grep --color=auto bash
4,5 - will check.