Oct
23
*nix command of the day
Filed Under technical
I’m taking a few days of training this week for a specific suite of products. During class today I learned about a really simple command: pgrep. It lets you grep through running processes based on numerous attributes. For years I’ve always done something like ps auxww | grep foo when all I really needed was pgrep foo. Why didn’t anyone ever enlighten me? Think of how many fewer characters I could have typed in my lifetime …
No, it’s not earth-shattering, and it’s not like I was using cat file.txt | wc -l rather than wc -l file.txt. (Now that would be embarrassing.) Still, it’s refreshing every now and then to learn simpler ways to do things.
Comments
3 Responses to “*nix command of the day”
Leave a Reply
You’re the one that taught me ps auxww | grep foo, and now you’ve taught me the replacement.
I don’t know if I ever realized how significant you were in my computing life. You essentially taught me how to use Linux and vim.
Thanks man.
pgrepis quite nifty. If you use-flyou get a nice long format.Along the same lines are you familiar with
pkill? This would, for example, allow you to do apkill sysloginstead of doing something likepgrep syslog&kill $PIDor akill `pgrep syslog`When I’m feeling particularly verbose I will do a
cat file.txt | wc -l, but I do know better.Topherone, I’m glad I still have the opportunity to “clarify” things I’ve passed along in the past under the guise of being helpful.
It warms my heart to know I helped steer someone away from nastiness and toward a true text editor. (I don’t have anything against emacs. It’s just fun to taunt people.) Seriously, though, thanks for the comments, Topher.
And Jay, I did find
pkillmoments afterpgrep, as the man page forpgrepreferenced it. I then went out to find what otherp*commands I might not know about. The most interesting one waspinky, a lightweight version offinger. Not particularly useful, but it amused me.