New answers tagged

1 vote
Accepted

How to convert all newlines to "\n" in POSIX sh strings

Try awk with: string='x y ' new_string=$( LC_ALL=C awk -- ' BEGIN { gsub("\n", "\\n", ARGV[1]) printf "%s", ARGV[1] }' "$string" ) In any ...
Stéphane Chazelas's user avatar
0 votes

Is it possible to get a character at terminal cursor using ANSI escape codes?

The DECRQCRA escape sequence allows you to query the checksum of a rectangular area. The checksum is basically the sum of the character codes there. And if you choose a 1×1 rectangular area then... ...
egmont's user avatar
  • 5,790
1 vote

How to interpret \e[H\e[2J ANSI escapes sequence from Linux terminal?

\e[H moves the cursor home (top left corner) and \e[2J clears the screen (the regularly viewed part, but not the scrollback). In many terminal emulators \e[2J simply clears the regularly viewed part ...
egmont's user avatar
  • 5,790
1 vote

groff -mandoc creating "ESC[1m" versus overstriking with backspace for bold text

You can abuse script and less to convert the backspace sequences: script --return --quiet -c "printf '.Dd today\n.Sh NAME\n' | groff -mandoc -Tutf8 | less" /dev/null | od -c … 0000200 1 ...
Chris Davies's user avatar
2 votes
Accepted

groff -mandoc creating "ESC[1m" versus overstriking with backspace for bold text

Debian Bookworm configures groff 1.22 for the old backspace-overwrite behavior you see there, and documents it in their patched grotty manual page along with how to revert to the newer SGR (\e[1m-like)...
egmont's user avatar
  • 5,790

Top 50 recent answers are included