0

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.

Community
  • 1
  • 1
mmar
  • 1,840
  • 6
  • 28
  • 41

1 Answers1

2
cat stack | grep -E '(^|\s)mongodb.databasename=dbname($|\s)'
dkx22
  • 1,103
  • 1
  • 13
  • 25