mmar
mmar

Reputation: 2030

Search the exact matched line from a file with grep

I have a property file with below contents.

mongodb.databasename=dbname
#mongodb.databasename=dbname

from this i need to take out the line which has only "mongodb.databasename=dbname". I tried with

cat app.properties | grep mongodb.databasename=dbname

but it retrieves both the line as a result. i tried with many options line -w, -F, -h but i couldn't get what i need. Could anyone help me how shouldi get only the exact matched line. I tried from this also "How to make grep only match if the entire line matches?" but i couldn't get what i need.

Upvotes: 0

Views: 39

Answers (1)

dkx22
dkx22

Reputation: 1133

cat stack | grep -E '(^|\s)mongodb.databasename=dbname($|\s)'

Upvotes: 2

Related Questions