How to ignore comment lines on word search

debian linux

file 1.txt containing

Select InvoiceId,InvoiceAmt
From Invoice
Select *
From InvoiceDet
-- Select * From Invoice

grep -E '\bInvoice\b' ./1.txt

From Invoice
-- Select * From Invoice

How do I ignore
-- Select * From Invoice
Brad JonesAsked:
Who is Participating?
To exclude the lines with SQL comment mark, I would do the following:
$ grep -E '^[^-]{2}.+\bInvoice\b' ./1.txt

Open in new window

Brad JonesAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.