How to Remove ^[, and All of the Escape Sequences in a File Using Linux Shell Scripting

How to escape the escape character in bash?

Well, you should be able to use this command:

rm $'\033\033'

More info on how $'...' works can be found here.


Note that ls might display a file named $'\033\033' as ''$'\033\033'. Doesn't matter much though, rm ''$'\033\033' would also work fine as the two leading single quotes just form an empty string.

How to remove escape char from string in bash using sed?

try this:

.......|sed 's@\\@@g'

or:

.......|sed "s@\\\\@@g"

EDIT add a test output:

kent$  echo "http:\/\/stackoverflow.com\/questions\/ask"|sed "s@\\\\@@g"
http://stackoverflow.com/questions/ask

kent$ echo "http:\/\/stackoverflow.com\/questions\/ask"|sed 's@\\@@g'
http://stackoverflow.com/questions/ask

How to remove terminal control escape sequences in the file?

I solved this issue using lots of regular expressions according to http://invisible-island.net/xterm/ctlseqs/ctlseqs.html



Related Topics



Leave a reply



Submit