0

When I run a program that outputs "\n" to the terminal, I'd like to configure the terminal beforehand (perhaps via stty) to not do a Carriage Return, but to only move the cursor down a row. To actually consider it a Line Feed, and not to perform a Carriage Return.

For example, if the program prints "123\n456", I would like to see:

123
   456

but I, of course, currently see:

123
456
Andy
  • 10,275
  • 5
  • 29
  • 33

1 Answers1

1

man stty says:

   * [-]onlcr
          translate newline to carriage return-newline

So we can turn it off, print something, and turn it on again:

$ stty -onlcr; printf '\rfoo\nbar\r\n'; stty onlcr
foo
   bar
Andy
  • 10,275
  • 5
  • 29
  • 33
that other guy
  • 109,738
  • 11
  • 156
  • 185