[sf-lug] ps and grep
jim stockford
jim at well.com
Thu Mar 6 18:24:04 PST 2008
(sorry, i can't help it: )
try
$ ps alx | grep " " | grep " "
the alx argument tells ps to format its output to
include the parent process id for each process
as well as the process id for each process.
you should see the entire output of the ps
command because ps sends it all to the first
grep command which passes along all lines
that have at least one space character to the
second grep command which passes on all
lines that have two space characters to your
terminal output.
well, all lines are certain to have two space
characters, so you'll see 'em all and you'll see
at the bottom that the two grep commands were
loaded before the ps command, which will be
below them.
On Mar 6, 2008, at 6:10 PM, jim stockford wrote:
>
> in general, the shell is designed to read a command
> line from the right to the left.
> in the case of ps | grep, you're asking grep to read
> the output of the ps command. if you run the ps command
> before grep is loaded, ps will have shot its wad prematurely,
> then grep will load and feel like it was stood up. so grep
> has to be loaded first so's to be waiting there to catch
> whatever ps shoots.
>
>
>
> On Mar 6, 2008, at 5:57 PM, Christian Einfeldt wrote:
>
>>
>>
>> On Thu, Mar 6, 2008 at 5:48 PM, Tom Haddon <tom at greenleaftech.net>
>> wrote:
>>>
>>> On Thu, 2008-03-06 at 17:47 -0800, jim stockford wrote:
>>>>
>>>> at the point you type the ps command and hit
>>>> enter, you've kicked off a new process, something
>>>> like
>>>> $ ps aux | grep doit
>>>>
>>> Do you mean that for grep to process ps's output, grep has to be
>>> loaded
>>> first? If so, this all makes sense, and I think I have it.
>>
>> I thought that grep always came second, because there has to be
>> something to grep.
>
>
> _______________________________________________
> sf-lug mailing list
> sf-lug at linuxmafia.com
> http://linuxmafia.com/mailman/listinfo/sf-lug
>
More information about the sf-lug
mailing list