ps aux command to list only files in brackets
Hi everybody,
I am looking to do the following: give a command line starting with ps aux that will print only entries with square brackets around the command field. I need to use a pipe after ps aux and keep in mind that the COMMAND field comes last in the output. I believe I need to create a way to list files that are in brackets only. I've been able to create a command to exlclude files in brackets by typing the following: grep -v ] But I need to know how to create the opposite effect, and list only the files in brackets. Can anybody help? Sorry for being such a beginner, but this problem has got me stumped. Thanks! |
try this, you might have to change the # value in the awk command, but this should get you started:
Code:
ps -aux | grep -v grep | awk '{print $11}' | grep -e ] grep -v grep = the -v excludes what is after the -v, in this case it will not display itself in the search awk '{print $11}' = this will print ONLY the 11th field of the ps -aux grep -e ] = this will look for ONLY matching the ] in the search. hope that helps. |
Code:
ps aux|awk '/\]/{print $11}' |
now that is a much cleaner way of handling the search unSpawn. im learning. that is more to what i was wanting to do, but could not figure it out fast enough.
|
Then you might like David the H.'s advice and pointers here.
|
thank you everybody! This accomplished exactly what I was looking to do.
|
I was looking for that
|
the right answer to this is ps aux|grep -e ]$
|
Quote:
The OP wants the commands only, not all the other output: Code:
root 1 0.0 0.0 8356 816 ? Ss 07:50 0:01 init [2] Have a look at this: Code:
ps ax -o args | grep -e "\]" |
Quote:
How about: Code:
ps ax -o args | grep -e "\]" | grep -v grep |
Quote:
Quote:
*BTW if the objective would have been to find kernel threads then they're children of kthread (2.6) or kthreadd (3.x) which could be expressed as 'pgrep kthread; pgrep -P $(pgrep kthread)'. For user land processes pgrep works as well: 'pgrep -f "\[";'. |
if you work as an admin you need to resolve things quickly. that means you need to find a short way, less type and resolve things faster.
so I would stick with: ps aux|grep -e ]$ |
All times are GMT -5. The time now is 11:49 AM. |