Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 747759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:14:33+00:00 2026-05-14T14:14:33+00:00

Im trying to understand how boolean logic works when I use NOT. To give

  • 0

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

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:14:34+00:00Added an answer on May 14, 2026 at 2:14 pm

    I will try to give a gut feeling or your boolean expressions, for maths other posters did it very well.

    Your boolean expression must be true for the lines you want to keep.

    • !PORT means the line does not contain PORT
    • !CORE means the line does not contain CORE

    Hence your boolean expression means keep the lines that as the same time does not contains PORT and does not contains CORE. Obviously there is no such lines in your file…

    You must use or because what you truly want to express is keep the lines that does not contain both PORT and CORE, but as you can see there is only one negation in the above statement. You are trying to say something like: does line contain PORT, does it also contains CORE then I do not want it. And that is !(/CORE/ && /PORT/), and using boolean math you can also write that /!CORE/||/!PORT/ as you have seen by yourself.

    Generally speaking negative assertions are difficult to understand. I’m not the only one to say that. For example, Damian Conway in Perl Best Practice pointed it out and recommanded using positive statements whenever possible (and use unless Perl operator instead of if when you want to negate a condition).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is
After trying to understand why client code is not rendered in a page (injected
I've been trying to understand how Ruby blocks work, and to do that I've
I've been trying to understand Process.MainWindowHandle . According to MSDN; The main window is
I'm trying to understand someone else's Perl code without knowing much Perl myself. I
I am trying to understand some assembly. The assembly as follows, I am interested
I was trying to understand something with pointers, so I wrote this code: #include
I'm trying to understand the concepts behind DDD, but I find it hard to
I'm trying to understand a particular Perl code from vcake . Usually I find
I'm trying to understand how you are supposed to add page numbers to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.