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: `^'
sed
command 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 oftata
withfofo
/toto
withbar
, or just set the value ofdb.username
tofofo
and that ofdb.password
tobar
? Your examples implies the latter, but please specify it explicitly in your question.