[1+1=2]

OneAndOneIs2

« My friend vicTo understand the command line... »

Fri, Oct 05, 2012

[Icon][Icon]Some more little tweaks

• Post categories: Omni, Technology, My Life, Programming, Helpful

If you use the command line often, you'll often find yourself in the position of needing to know if a particular process is running.

This is easy enough to do - something like

ps aux

will show you all runnign processes.

But if you want it to just find your own processes, then you'll probably be lazy and grep it for your username:

ps aux | grep myname

There's a better way, though:

ps u -U myname

will save you the effort of grepping for your own name. But it's a bit of a PITA to type.

So a handy alias to set up is

alias pm='ps u -U $USER'

With this alias, just running "pm" shows you all your processes. Nice & simple.

But with applications like Gnome & KDE, you often get so many processes running that you want to filter down even further, to just the one(s) you're interested in. Still simple:

pm | grep interesting

Except if you've ever done this, you'll know you always get the annoying output of:

djh      15367  1.5  1.7 186844 175740 pts/42  S+   15:29   0:11 interesting
djh      25743  0.0  0.0   3372   760 pts/84   S+   15:42   0:00 grep interesting

The "grep" process itself contains the "interesting" string you're after. When you're in a hurry, this unwanted output can be a real pain.

So how about adding this function to your .bashrc:

function grp {
    grep $@ | grep -v grep
    }

And now when you run

pm | grp interesting

you'll get the process you wanted without the clutter of that unwanted grep.

They're two tiny, trivial changes that will save you barely a second a day.

But I already forgot how I managed to live without them...


1 comment

Yuta
Comment from: Yuta [Visitor]
Thanks! neat and useful = )
26/10/12 @ 15:08
 

[Links][icon] My links

[Icon][Icon]About Me

[Icon][Icon]About this blog

[Icon][Icon]My /. profile

[Icon][Icon]My Wishlist

[Icon]MyCommerce

[FSF Associate Member]


December 2017
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Search

User tools

XML Feeds

eXTReMe Tracker

Valid XHTML 1.0 Transitional

Valid CSS!

[Valid RSS feed]

powered by b2evolution free blog software