Daniel Smith
Daniel Smith

Reputation: 77

ASCII underline escape code for Linux terminal capabilities

In a Linux terminal emulator with xterm capabilities, printing the escape code \x1b[4m will make the following characters print with an underline.

In the Linux console with linux term capabilities, printing the escape code \x1b[4m causes the following characters to be printed in blue.

How do I print underlined text in a Linux console?

When I mention "linux" or "xterm" term capabilities I'm talking about the output of $echo $TERM.

Upvotes: 1

Views: 1510

Answers (1)

Philippe
Philippe

Reputation: 26895

Instead of \x1b[4m, try $(tput smul)

printf "%s\n" "$(tput smul)This is underlined"

Upvotes: 3

Related Questions