For example: Here is some example text that contains ^[[31mred^[[m and ^[[32mgreen^[[m words that I would like to wrap neatly. Hidden character may refer to: A non-printing character in computer-based text processing and digital typesetting. The easiest way is probably to use the stream editor sed to remove the M characters. This reply is very short and lacks a minimum of explanation, so it is candidate for deletion. How do I avoid m in Linux Remove CTRL-M characters from a file in UNIX. 'man strings' will provide the documentation. It effectively is removing all the non-printable characters. But as I understand, the caret notation only applies to non-printing characters in the ASCII alphabet. To clarify my real-world example, I've got text where some words are in colour (using ANSI escape sequences) and I'd like that to wrap neatly. The strings program will take all printable characters, in this case of length 1 (the -1 argument) and print them. cat has a -v option which converts non-printing characters to their caret notation (which is useful if we dont want the terminal to interpret the control characters literally in cat output).
![what are non printing characters linxu what are non printing characters linxu](https://www.linuxlinks.com/wp-content/uploads/2018/09/cdls-help.png)
![what are non printing characters linxu what are non printing characters linxu](https://linuxhint.com/wp-content/uploads/2019/08/16.jpg)
The example above is really to simplify and demonstrate the problem but I may have over-simplified. Is there something (ideally something standard) that can wrap text whilst accounting for non-printable characters? I can't see any switches that say to account for non-printing characters, and the PS1 approach to flagging non-printing characters doesn't seem to work with fold or fmt. (where ^[ is the escape character) intuitively ought to produce the same thing in green text, but instead produces: 1 2 3 4 5 6 7
![what are non printing characters linxu what are non printing characters linxu](https://usermanual.wiki/Pdf/manual.980920320-User-Guide-Page-1.png)
Depending upon how the strings program was configured it will default to either displaying all the printable sequences that it can. For example: fold -w 20 -s <<<`seq 1 25`Īs one might expect, produces: 1 2 3 4 5 6 7 8 9īut: fold -w 20 -s <<<^[[32m`seq 1 25`^[[m DESCRIPTION For each file given, GNU strings prints the printable character sequences that are at least 4 characters long (or the number given with the options below) and are followed by an unprintable character. The most common non-printable characters in word processors are pilcrow, space, non-breaking space, tab character etc. This question asks about wrapping text at a certain column, and people suggest using fold or fmt but as far as I can see, these simply count characters and don't allow for non-printing characters. Non-printing characters or formatting marks are characters for content designing in word processors, which are not displayed at printing.It is also possible to customize their display on the monitor.