I cant really wrap my head around BOOLEAN logic when I use NOT together with AND and OR

Posted by Bq on Stack Overflow See other posts from Stack Overflow or by Bq
Published on 2010-04-29T09:24:16Z Indexed on 2010/04/29 9:27 UTC
Read the original article Hit count: 307

Im trying to understand how boolean logic works when I use NOT. To give an example using awk

I have a text file containing

CORE
PORT
CORE 
PORT
COREPORT
CORE
COREPORT

And I would like to remove all COREPORT lines. The way I thought I would do it was with (NOT CORE) AND (NOT PORT) eg

awk '/!CORE/&&/!PORT/{print}'

But when I try it out Im actually supposed to use OR instead of AND

awk '/!CORE/||/!PORT/{print}'

I would be really glad if some one could explain where my thinking is wrong and super glad if it could be visualized with a venn diagram or something like the boolean machine at kathyschrock

© Stack Overflow or respective owner

Related posts about boolean-logic

Related posts about awk