Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • thanks to both answers. i felt i should make something as a good answer, although both give regexps, which i wanted to avoid. chose this one as it gives a reference for the format. Commented Jun 16, 2011 at 12:49
  • @andrew: My regexp is flexible enough that I expect it to work with pretty much any now-existing terminal, and probably with any tomorrow-existing terminal as well. I haven't tested it much, so there might be bugs, but the approach is sound as control sequences follow a few general patterns. Commented Jun 16, 2011 at 13:53
  • please provide how to use this script. does it require pipe input? or positional arguments? Commented Jan 5, 2018 at 17:14
  • 1
    @TrevorBoydSmith Either will work for input, and the output is always on standard output, like typical text utilities. Commented Jan 5, 2018 at 20:31
  • This mangles multibyte characters such as ☺ (\xe2 \x98 \xba). The [\x80-\x9f] clause strips the middle byte. Commented Jun 9, 2018 at 4:52