[TriLUG] Change string with special character

Craig Taylor ctalkobt at gmail.com
Fri May 18 12:01:58 EDT 2007


On 5/18/07, Thomas <thomasvt at gmail.com> wrote:
>
> Hello,
>
> I need to change a string in a file
>
> \303\215 (all characters) with Í (LATIN CAPITAL LETTER I WITH ACUTE
> ie: echo '\0315')
> [...]
> Thanks,
> Thomas
>



echo '\303\215' | sed "s/[\\]303[\\]215/@/" | tr "@" "\315"

Note that I couldn't get the character 315 in the sed string directly so I
used a '@' temporarily. TR is only for characters so won't work here.

Note: There's probably a better way to represent literal \ in a sed string
but [\\] works and I did it with-out use of the man page. :-)

Feel free to change '@' to '@SOMELONGSTRING' that won't match anything else.



More information about the TriLUG mailing list