2

Is there a way to read in and process control characters like ^M and only show the final output? For example, I have the following string:

track^Mfl^Ms

I would like to convert it to:

slack

How could I go about doing this?

1
  • 4
    col -b should help. Commented Jan 31, 2019 at 23:52

1 Answer 1

2

It is already mentioned in the comments but it probably should be the answer:

col -b should help

1
  • 1
    Note that \r/^M is not the only control character/sequence it recognises. The BSD one (often the one also found on Linux-based systems) interprets the input as a Teletype Model 37 would (not like modern terminals would). In particular SPC does not erase, it moves the cursor forward one position, so abc\rA C would render as AbC, not A C. Commented Jun 17, 2020 at 17:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.