[SOLVED] ps aux command to list only files in brackets
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
If you find yourself using 'ps|grep something|grep -v grep' a lot then know there's pgrep.
Quote:
Originally Posted by druuna
Both answers given by lleb and unSpawn are not fully correct either; They only print field 11 and there can be more (see the above example).
You're right.
*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 "\[";'.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.