2017-06-14 42 views
0

我有一個包含雙引號像這樣的字符串:如何刪除從一開始雙引號和字符串的結尾

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

我想用setgrep刪除在雙引號開始和在它的結束,輸出應該是這樣的:

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

我用:sed -e 's/\"//g'但是這會刪除所有"在一個字符串

+1

'sed的-i.bak -E 's/^ 「|」 $ // G' file' – anubhava

回答

1

您需要使用線錨

$ echo '"[{"clientid":"*", "identityzone":"*"}]"' | sed 's/^"//; s/"$//' 
[{"clientid":"*", "identityzone":"*"}] 
0

容易:

sed 's/^\"\(.*\)\"$/\1/g' <<<'"[{"clientid":"*", "identityzone":"*"}]"' 
相關問題