[EMAIL PROTECTED] wrote:
> Hi,
> 
> In order to get an email advising me that a process is using too much
> %cpu, i wanted to be able to redirect the output of the Unix top command
> into a text file, then use regular expressions to get the data i need.
> 
> However, redirecting top's output into a file, ends up being one long
> line with a lot of  control-M characters and other funny characters like
> these:
> 
> 1 running^M^[[BCpu states:^M^[[BCPU
> 
> Is there a way to parse the file, as you would go through a normal text
> file.

You could just convert the ^M (\r) to newlines and then you can remove
the escape sequences if needed or just work around them.

        tr/\r/\n/;
or
        s/\r/\n/gs;

-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to