Re: [Help-bash] Using single quotes to escape a newline
From:
Greg Wooledge
Subject:
Re: [Help-bash] Using single quotes to escape a newline
Date:
Thu, 30 Jul 2015 08:01:43 -0400
User-agent:
Mutt/1.4.2.3i
On Wed, Jul 29, 2015 at 05:28:56PM -0700, Michael Convey wrote:
> Are you saying that when echo sends its output to stdout, and only when
> stdout is the terminal, the kernel converts the <newline> to \r\n?
There's nothing special about echo in this situation. The same thing
happens when ANY program writes data to a terminal, and the terminal is
in the correct mode.
The behavior of a terminal (driver) is controlled by various flags that
a shell program can read or set using stty(1). stty calls this particular
flag "onlcr" (Output NewLine => CarriageReturn).
In the HP-UX manual:
onlcr (-onlcr) Map (do not map) newline character to a
carriage-return/newline character sequence on
output.
In the Debian manual:
* [-]onlcr
translate newline to carriage return-newline
> In \r\n
> does \r = <CR> (carriage return) and \n = <newline>????
Yes.