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
03-02-2012, 04:56 PM
Pandu Poluan
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,
03-02-2012, 05:02 PM
Paul Hartman
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 } }'
03-02-2012, 05:03 PM
Tanstaafl
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)?
03-02-2012, 05:12 PM
Tanstaafl
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...
03-02-2012, 05:12 PM
Jason
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 } }'"
03-02-2012, 05:24 PM
Pandu Poluan
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,
03-02-2012, 05:30 PM
Alan McKinnon
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
03-02-2012, 05:32 PM
Tanstaafl
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!
03-02-2012, 06:32 PM
Paul Hartman
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}'