On Mon, Nov 8, 2010 at 1:19 PM, Michael Torrie <[email protected]> wrote:
> On 11/08/2010 10:21 AM, Kenneth Burgener wrote:
> > stringing several external commands is more
> > complicated (very simple in bash an Perl), but Python does have good
> > readability and vast libraries, and is becoming the popular choice.
>
> I used to think this as well. Then I realized I was using Python wrong.
> The only reason you string things together in Bash is usually because
> Bash really doesn't do much on its own. So you'd do something like:
>
> ps ax | grep blah | grep -v grep | awk ' { print $1; }'
>
> Whereas in Python you could simply execute the ps ax command and then
> process the output through generators as I describe in the like in my
> previous post.
>
> With the expressive power of generators, it makes up quite nicely for
> the lack of easy subprocess piping.
>
> /*
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
> */
>
Or....
ps ax | awk '!/awk/ && /blah/ {print $1}'
:)
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/