[CentOS] Log File Reviewing

Les Mikesell lesmikesell at gmail.com
Mon Jan 5 21:58:10 UTC 2009


Spiro Harvey wrote:
>> Why not just start with perl which does more than sed/awk while using 
>> similar syntax (if you want)?
> 
> This is why:
> 
> awk '/^[[:space:]]*word/ {print}' logfile
> 
> vs
> 
> perl -ne 'if (/^\s*word/) { print $_; }' logfile
> 
> 
> Which syntax is likely to be easier to remember? 

I never remember the awk syntax because if it is really that simple I'd 
use grep with it's implied print.  But it's almost never really that 
simple and you end up needing things that are difficult in awk but easy 
in perl.  Perl can use the posix names for character classes too if you 
like to type and how can you forget the 'if (expresssion) {action}; 
syntax?  Also you could have omitted the $_ argument to print, since it 
is assumed if you are looking for simplicity.

-- 
   Les Mikesell
    lesmikesell at gmail.com



More information about the CentOS mailing list