Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Output from man command have bold and underline text that is recoginzed by less

like H\x08HE\x08EL\x08LL\x08LO\x08O display HELLO or H\x08_E\x08_L\x08_L\x08_O\x08_ as underline HELLO

what is the name of this formatting?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

The method is called overstriking or overtyping, and goes back to the days of typewriters.

Byte 0x08 (aka \x08 or ^H) is the ASCII "Backspace" character. With typewriters and line-printers, it would move the cursor back one character, so the following character would be printed on paper at the same position as last one. Most commonly, either a character is overstruck over itself (resulting in bold text), or over an underscore _ (resulting in underlined text).

Computer terminals normally also delete the backspaced-over character, so this method would no longer work. However, many pagers such as less (the default pager used by man) or w3m automatically translate the two cases mentioned above into actual bold/underline formatting.

(See also ASA carriage control characters used by mainframes and line printers; they have an "overstrike last line" option instead of using Backspace.)

Compare this to combining characters found in Unicode.

share|improve this answer
2  
Note that \b on a terminal doesn't delete the character, it's just that in H\b_, _ replaces the H (it's _ that deletes H, not \b). Also note that there are Unicode underlining combining characters nowadays so another way to write an underlined H is to write a H followed by U+0332 like . (which my firefox doesn't render properly btw). –  Stéphane Chazelas Mar 8 at 18:54
add comment

That's plain ASCII, nothing special about it. The \x08 is ASCII code for backspace so the first one does H-backspace-HE-backspace-E... (writes every character twice) and the second does H-backspace-_ and so on. It's what you would do on a typewriter to get bold and underline.

On the other hand, to handle color, you output ASCII escape codes that are interpreted by the virtual terminal to show color, blink, position cursor and so on. It's how commands like ls write in color:

http://en.wikipedia.org/wiki/ANSI_escape_sequences

To allow less to preserve the ASCII escape codes, you call it as less -R. For instance, this command displays ls output in color in less:

/bin/ls --color -B -F -1 | less -R

Which I have as alias to lsl.

share|improve this answer
    
But this backspace and next character need to be processed by terminal, it need to be called somehow. –  jcubic Mar 8 at 10:42
    
@jcubic: Not everything in the world has a name. It might easily have been "that odd thing some terminals do". –  grawity Mar 8 at 10:42
    
Well terminals speak ASCII, that's actually the reason ASCII was invented. First 32 codes in ASCII are typewriter stuff like "tab", "carriage return", "line feed", "delete", "vertical tab" and so on, together with old-school remote terminal stuff to handle communication (start/end block, start/end stream,...). So your terminal is processing it all the time - newlines are done this way as well. –  orion Mar 8 at 10:44
    
most terminals speak ANSI they display colors and stuff, so I thought that this have a name from some old terminal type. –  jcubic Mar 8 at 10:49
    
Just to paraphrase what grawity said: ASCII escape codes also handle bold, underline, inverted (selected), background color and so on, so these "overstrike" options that would only work on real printer, are converted into escape codes by less. –  orion Mar 8 at 11:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.