Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for a script which given the following input:

A=0 B=0 C=0
A=0 B=0 C=0
A=0 B=0 C=0
A=0 B=0 C=0.01
A=0 B=0 C=0
A=0 B=0 C=2

would output all the lines where the field "C" is not zero, that is:

A=0 B=0 C=2
A=0 B=0 C=0.01

One way to do it is grep "C=1" | "C=2" | "C=3".. but that's fairly inefficient obviously...

any idea ? this script would be running on windows (cygwin installed). If there is a way to do so involving 3rd party software (eg. excel) then that's of interest too....

share|improve this question
    
Will the values of A and B vary as well? If so, can they simply be ignored? –  DMA57361 Sep 8 '10 at 11:39
    
values of A and B can be ignored... what matters is being able to spot all lines where C is above zero (even if very slightly e.g. C=0.0001) –  elec Sep 8 '10 at 11:42

1 Answer 1

up vote 4 down vote accepted

what about grep -v C=0 , here -v means invert, so you will see lines does not include 'C=0'
even without grep, I guess you can use some slightly complex regex to do the same job (not so elegant though).

share|improve this answer
    
excellent, just what I was looking for... thanks. –  elec Sep 8 '10 at 12:35
    
You will need to do grep -v 'C=0$' to anchor the zero to the end of the line or it will exclude "C=0.01". –  Dennis Williamson Sep 8 '10 at 12:55
    
@Dennis sure. thanks for your graceful complementation. –  Jokester Sep 8 '10 at 12:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.