Reputation: 10362
With the following text file, test.txt
:
{\x22order\x22:\x22161332\x22,\x22name\x22:\x22chiller\x22,\x22code\x22:\x22chiller\x22}
{\x22order\x22:\x22161332\x22,\x22name\x22:\x22chiller\x22,\x22code\x22:\x22chiller\x22}
{\x22order\x22:\x22161332\x22,\x22name\x22:\x22chiller\x22,\x22code\x22:\x22chiller\x22}
How do I replace occurrences of \x22
with single quotation marks in Sed?
I've tried this with no avail: sed -i "s#\x22#'#g" test.txt
Upvotes: 0
Views: 376
Reputation: 203985
You need to escape the backslash to make it literal and you need to use '\''
to represent a single quote in a single-quote-delimited (which they all should be unless absolutely necessary to be otherwise) string or script
$ sed 's/\\x22/'\''/g' file
{'order':'161332','name':'chiller','code':'chiller'}
{'order':'161332','name':'chiller','code':'chiller'}
{'order':'161332','name':'chiller','code':'chiller'}
Upvotes: 2