• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8144
  • Last Modified:

How to use UNIX grep for find something wihch is not equal

I have a text file which has follwing lines;

asdada  ....      B=0
rwer    .....       B=233
gsggw .....     B=0
asfasf ....      b=234
.........................
..........................
.........................

How to use grep to get lines Which are NOT B=0. This means all lines which B>0

0
unknown_routine
Asked:
unknown_routine
1 Solution
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi unknown_routine,

grep won't evaluate the line and show you lines where B>0, but it can scan the lines at tell you where the string 'B>0' exist.  Or, as you seem to want where a string doesn't exist.

# find all lines with B=0

grep 'B=0' myfile

# find all lines that do not contain B=0

grep -v 'B=0' myfile

# find all lines with B>0

grep 'B>0' myfile



Good Luck,
Kent
0
 
unknown_routineAuthor Commented:
Good answer. With little midification it is what I need.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now