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

m.roth at 5-cent.us m.roth at 5-cent.us
Thu Dec 3 14:42:25 UTC 2009


> From: mark <m.roth at 5-cent.us>
>> John Doe wrote:
>> > From: hadi motamedi
>> >> Can you please do me favor and let me know if I can go further and
>> try for advanced search like finding how many rows inside a file have data
>> that does not start with a zero after the third comma ?
>> >
>> > Something like: awk -F, ' { print $4 } ' | grep -v "^0" | wc -l Use
>> one command at a time to see how they work with each other (you might have
>> to modify the grep a bit)...
>>
>> *sigh*
>>
>> Drive me crazy, why use multiple commands?
>>
>> awk -F 'BEGIN { FS = ","; }{if ( $3 !~ /^0 ) { count++; }} END { print
>> count }'
>> filename
>
> Oh no!!!  Don't get mad!!!  ^_^
> Teaching some UNIX pipes to a "beginner" can be helpful you know...
> And it is $4...

You're right, it is $4, but what do you want, I was still half asleep, and
getting ready to head to work....

And yeah, pipes are Good. I try to explain to folks why I call *Nix "fun",
and one reason is the huge toolset that's *intended* to work together.

        mark



More information about the CentOS mailing list