[CentOS] Inquiry:How to compare two files but not in line-by-line basis?

Les Mikesell lesmikesell at gmail.com
Mon Dec 7 13:48:23 UTC 2009


mark wrote:
> Les Mikesell wrote:
>> Awk is just too weird for normal people.  I wouldn't even suggest reading that 
>> manual.  If you can't do what you want with regexps and a pipeline of simpler 
>> programs, you might as well use perl.
> 
> <Looks around, yeah, this *is* a list for sysadmins of Linux....>


Who have probably almost all started something in awk and ended up either 
needing a pipeline of other programs or switching to perl.  If your machine is 
powerful enough to run perl (and I can't imagine one that isn't in this century) 
you might as well use it because it does anything awk can do and more.  awk is 
almost as complicated to learn but can't do as much and is harder to debug. 
Maybe it made sense on computers of the 1970's, or before perl was available.

> ROTFLMAO!
>> But:
>> grep -v '^.*,.*,.*,0' filename |wc -l
>> seems simple enough and says what you mean.
>>
>> Or:
>> cut -d, -f4 | grep -v '^0' |wc -l
>>
> So, is there an obfuscated shell contest?

Shell commands are just what you'd type so you have to know it anyway so there 
is nothing special about making a program out of it. Other than grep using 
regexps the man pages for those programs are probably literally a page.  No one 
is going to understand awk or perl after reading a page. Personally I'd probably 
have loaded the file in vi, done ':v/^.*,.*,.*,0/d', then hit ctl-g to see how 
many lines were left, then u to put them back.

-- 
   Les Mikesell
    lesmikesell at gmail.com



More information about the CentOS mailing list