I'm trying to edit a text file programmatically, which contains a line like this:
db.username="tata"
db.password="toto"
which I want to look like this:
db.username="fofo"
db.password="bar"
Here is the regex :
^\s*db.username="([^"]*)
when i try to use this command
sed -i -E '^\s*db.username="([^"]*)' 'fofo' file.txt
I'm getting the error:
sed: -e expression #1, char 1: unknown command: `^'
sedcommand is incorrect. The syntax for replacements issed 's/regex/replacement text/' file. Also, please indicate how the solution you look for is to decide which line to act upon. Do you want to replace every occurence oftatawithfofo/totowithbar, or just set the value ofdb.usernametofofoand that ofdb.passwordtobar? Your examples implies the latter, but please specify it explicitly in your question.