Home > Mobile >  Postgres String FIlter using linux sed command
Postgres String FIlter using linux sed command

Time:08-18

this is my postgres connection for an Nodejs application. Can you show me how to replace "password": "******" using sed command? My current sed filter is working but that's wrong. Pls

POSTGRES_DB={"username":"postgres","password":"admin*****","database":"*****","host":"10.125.208.15","port":"5432","dialect":"postgres"}
That is my filter
's/"password":"..........."*/"password":"12345"/g'

That is output:

POSTGRES_DB={"username":"postgres","password":"12345","database":"****","host":"10.125.208.15","port":"5432","dialect":"postgres"}

CodePudding user response:

This can help:

sed 's/"password":"[^"]*"/"password":"admin123"/g'

Your password should be double quote free This command substitute (s) this phrase "password":"[^"]*" with this one "password":"admin123" globally (g) - replace all matches

Where [^"] means any character expect double quote and * means random count

  • Related