bash - replace double quoted hash with sed -


i have problem replacing default password hash in config file:

sed -i 's/default_password_crypted: "[^"]*"/default_password_crypted: "\$1\$mf86/uhc\$wvcicxred6crbz2onwxyac."/' input.txt 

i following error:

sed: -e expression #1, char 74: unknown option `s'

works:

search pattern: default_password_crypted: "$1$mf86/uhc$wvcicx2t6crbz2onwxyac."  sed -i 's/default_password_crypted: "[^"]*"/default_password_crypted: "1234567890"/' input.txt 

how need write replace pattern hash ?

thx

you need escape literal / inside replacement it’s delimiter:

sed -i 's/default_password_crypted: "[^"]*"/default_password_crypted: "\$1\$mf86\/uhc\$wvcicxred6crbz2onwxyac."/' input.txt 

or use different character, example ,:

sed -i 's,default_password_crypted: "[^"]*",default_password_crypted: "\$1\$mf86,uhc\$wvcicxred6crbz2onwxyac.",' input.txt 

you don’t need escape $ inside replacement.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -