Foudel Foudel -4 years ago 66
Bash Question

How to delete double quotes from the beginning and the end of a string

I have strings which contain double quotes like this one:

"[{"clientid":"*", "identityzone":"*"}]"

I would like to use
to delete the double quotes at the beginning and at the end of it, the output should look like :

[{"clientid":"*", "identityzone":"*"}]

I have used :
sed -e 's/\"//g'
but this deletes all the
in a string

Answer Source

You need to use line anchors

$ echo '"[{"clientid":"*", "identityzone":"*"}]"' | sed 's/^"//; s/"$//'
[{"clientid":"*", "identityzone":"*"}]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download