Remove ^H and ^M characters from a file using Linux shell scripting

Viewed 29313

How do I remove ^H and ^M characters from a file using Linux shell scripting?

^[[0^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H   rcv-packets: 0
^[[0^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H      rcv-errs: 0
     rcv-drop: 0
     rcv-fifo: 0
     rcv-frame: 0
6 Answers

if you want to change original file, do this:

sed -i '.bak' 's/^M//g ; s/^H//g' test.md

(^M is control+v control+m)
(^H is control+v control+h)

much file, you can do this:

find source -name '*.md' | xargs sed -i '.bak' 's/^M//g ; s/^H//g'
Related