FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 03-02-2012, 04:46 PM
Tanstaafl
 
Default Filter grep output of 'ps aux'

Does anyone know if there is a way to filter the output of ps aux to
show only lines that have a value in the %CPU column higher than x - ie,
1.0, or 2.0, or something like that?


Thanks
 
Old 03-02-2012, 04:56 PM
Pandu Poluan
 
Default Filter grep output of 'ps aux'

On Mar 3, 2012 12:49 AM, "Tanstaafl" <tanstaafl@libertytrek.org> wrote:

>

> Does anyone know if there is a way to filter the output of ps aux to show only lines that have a value in the %CPU column higher than x - ie, 1.0, or 2.0, or something like that?

>

> Thanks

>


For that, you need awk instead of grep.


Rgds,
 
Old 03-02-2012, 05:02 PM
Paul Hartman
 
Default Filter grep output of 'ps aux'

On Fri, Mar 2, 2012 at 11:46 AM, Tanstaafl <tanstaafl@libertytrek.org> wrote:
> Does anyone know if there is a way to filter the output of ps aux to show
> only lines that have a value in the %CPU column higher than x - ie, 1.0, or
> 2.0, or something like that?

ps aux | gawk '{ if ( $3 > 1.0 ) { print } }'
 
Old 03-02-2012, 05:03 PM
Tanstaafl
 
Default Filter grep output of 'ps aux'

On 2012-03-02 12:56 PM, Pandu Poluan <pandu@poluan.info> wrote:


On Mar 3, 2012 12:49 AM, "Tanstaafl" <tanstaafl@libertytrek.org
<mailto:tanstaafl@libertytrek.org>> wrote:
>
> Does anyone know if there is a way to filter the output of ps aux to
show only lines that have a value in the %CPU column higher than x - ie,
1.0, or 2.0, or something like that?
>
> Thanks
>

For that, you need awk instead of grep.


Never used awk... any chance you (or someone) could provide an example
of how to do this?


Also - would there be a way to get a running output (kind of like
tailing a log)?
 
Old 03-02-2012, 05:12 PM
Tanstaafl
 
Default Filter grep output of 'ps aux'

On 2012-03-02 1:02 PM, Paul Hartman <paul.hartman+gentoo@gmail.com> wrote:

On Fri, Mar 2, 2012 at 11:46 AM, Tanstaafl<tanstaafl@libertytrek.org> wrote:

> Does anyone know if there is a way to filter the output of ps aux to show
> only lines that have a value in the %CPU column higher than x - ie, 1.0, or
> 2.0, or something like that?

ps aux | gawk '{ if ( $3> 1.0 ) { print } }'


Thanks Paul! Thats a huge help...

Now if I could just get a constantly updated output of this (like
tailing a live log), I'd be in heaven...


But if this is the best I can do, it is 1000 times better...
 
Old 03-02-2012, 05:12 PM
Jason
 
Default Filter grep output of 'ps aux'

On Fri, Mar 02, 2012 at 01:03:55PM -0500, Tanstaafl wrote:
> Also - would there be a way to get a running output (kind of like
> tailing a log)?

watch -n1 "ps aux | gawk '{ if ( $3 > 1.0 ) { print } }'"
 
Old 03-02-2012, 05:24 PM
Pandu Poluan
 
Default Filter grep output of 'ps aux'

On Mar 3, 2012 1:07 AM, "Paul Hartman" <paul.hartman+gentoo@gmail.com> wrote:

>

> On Fri, Mar 2, 2012 at 11:46 AM, Tanstaafl <tanstaafl@libertytrek.org> wrote:

> > Does anyone know if there is a way to filter the output of ps aux to show

> > only lines that have a value in the %CPU column higher than x - ie, 1.0, or

> > 2.0, or something like that?

>

> ps aux | gawk '{ if ( $3 > 1.0 ) { print } }'

>


Why would you use "if"? You can easily use this :


ps aux | awk '$3 > 1.0 {print}'


Rgds,
 
Old 03-02-2012, 05:30 PM
Alan McKinnon
 
Default Filter grep output of 'ps aux'

On Fri, 02 Mar 2012 13:12:04 -0500
Tanstaafl <tanstaafl@libertytrek.org> wrote:

> On 2012-03-02 1:02 PM, Paul Hartman <paul.hartman+gentoo@gmail.com>
> wrote:
> > On Fri, Mar 2, 2012 at 11:46 AM,
> > Tanstaafl<tanstaafl@libertytrek.org> wrote:
> >> > Does anyone know if there is a way to filter the output of ps
> >> > aux to show only lines that have a value in the %CPU column
> >> > higher than x - ie, 1.0, or 2.0, or something like that?
> > ps aux | gawk '{ if ( $3> 1.0 ) { print } }'
>
> Thanks Paul! Thats a huge help...
>
> Now if I could just get a constantly updated output of this (like
> tailing a live log), I'd be in heaven...
>
> But if this is the best I can do, it is 1000 times better...
>

try "watch"

--
Alan McKinnnon
alan.mckinnon@gmail.com
 
Old 03-02-2012, 05:32 PM
Tanstaafl
 
Default Filter grep output of 'ps aux'

On 2012-03-02 1:12 PM, Jason <gentoo@lakedaemon.net> wrote:

On Fri, Mar 02, 2012 at 01:03:55PM -0500, Tanstaafl wrote:

Also - would there be a way to get a running output (kind of like
tailing a log)?


watch -n1 "ps aux | gawk '{ if ( $3> 1.0 ) { print } }'"


Perfect!!!

Thanks so much guys!
 
Old 03-02-2012, 06:32 PM
Paul Hartman
 
Default Filter grep output of 'ps aux'

On Fri, Mar 2, 2012 at 12:24 PM, Pandu Poluan <pandu@poluan.info> wrote:
>
> On Mar 3, 2012 1:07 AM, "Paul Hartman" <paul.hartman+gentoo@gmail.com>
> wrote:
>>
>> On Fri, Mar 2, 2012 at 11:46 AM, Tanstaafl <tanstaafl@libertytrek.org>
>> wrote:
>> > Does anyone know if there is a way to filter the output of ps aux to
>> > show
>> > only lines that have a value in the %CPU column higher than x - ie, 1.0,
>> > or
>> > 2.0, or something like that?
>>
>> ps aux | gawk '{ if ( $3 > 1.0 ) { print } }'
>>
>
> Why would you use "if"? You can easily use this :
>
> ps aux | awk '$3 > 1.0 {print}'

because I don't know awk very well
 

Thread Tools




All times are GMT. The time now is 09:54 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org