Hi, All:
Suppose this is the file content I have, and I need to do some "translation" to specific characters.File content or some string like this:
This is a decoding process.
We have to do this.\\1aWe need \\7b CHANGE \\7d.
The characters that need decoding are:
'\\1a' ----> '\n'
'\\7b' ----> '{'
'\\7d' ----> '}'
...
...
Because we need a common decoding logic for processing, and
But when I try to use Array and sed to finish this job,I did some trial at first, but failed. I find I can't get what I want.
But the result output is this:
This isnThat is
The intended output should be like this:
This is
That is
Because we want the \\1a to be translated to \n, which means a newline.
Please help with such a issue, what can I do to finish this characters decoding appropriately???
Thank you very much!!
Suppose this is the file content I have, and I need to do some "translation" to specific characters.File content or some string like this:
This is a decoding process.
We have to do this.\\1aWe need \\7b CHANGE \\7d.
The characters that need decoding are:
'\\1a' ----> '\n'
'\\7b' ----> '{'
'\\7d' ----> '}'
...
...
Because we need a common decoding logic for processing, and
But when I try to use Array and sed to finish this job,I did some trial at first, but failed. I find I can't get what I want.
Code:
set -A map_from '\\1a'
set -A map_to '\n'
echo "This is${map_from[0]}That is." | sed "s/${map_from[0]}/${map_to[0]/g"
This isnThat is
The intended output should be like this:
This is
That is
Because we want the \\1a to be translated to \n, which means a newline.
Please help with such a issue, what can I do to finish this characters decoding appropriately???
Thank you very much!!