[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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/

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

In the Debian manual:

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

> In \r\n
> does \r = <CR> (carriage return) and \n = <newline>????


reply via email to

[Prev in Thread] Current Thread [Next in Thread]