user710818
user710818

Reputation: 24248

How to select not commented rows?

I have file that contains:

# sdfdsfds fsf
var1=1232
#fdsfdsfds
#fdsfsdf
var2=456
..................

I need select only not commented rows - that not start from # Does it possible with grep? Thanks.

Upvotes: 0

Views: 116

Answers (4)

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57650

Use the -E option for regex and -v option for inverse matching.

grep -v -E '^#' file

Upvotes: 0

Ade YU
Ade YU

Reputation: 2362

You may use grep -v '^#'

The -v option is for not logic.

Upvotes: 1

NPE
NPE

Reputation: 500327

The following will do it:

grep -v ^# file.txt

Upvotes: 2

kev
kev

Reputation: 161674

use the -v(invert-match) option in grep:

$ grep -v '^#' file.txt
var1=1232
var2=456

Upvotes: 5

Related Questions