Re: CR/LF
On Sun, Dec 11, 2022 at 06:46:05PM +0100, tomas@tuxteam.de wrote:
> On Sun, Dec 11, 2022 at 08:54:27AM -0500, Greg Wooledge wrote:
> > 3) echo usually, but not always, adds an additional newline character to
> > the output. In most cases, this is acceptable, even preferable. But
> > when the OP is complaining of an "extra CR/LF" [sic], but is using
> > echo to produce the extra newline himself, well... there you have it.
>
> Now which cases, besides when the -n option is given (I don't know,
> off the bat, I must admit).
The other case is less common. I believe David already gave one
example of it.
On some platforms, the "echo" command (e.g. the one in /bin) has System V
semantics. In bash, you can also put the builtin echo command into SysV
mode by giving the -e option.
When echo is operating in SysV mode, the \c escape sequence suppresses
the generation of a newline.
unicorn:~$ echo -e 'xx\c'
xxunicorn:~$
In bash, it also appears to truncate the arguments right at that point.
unicorn:~$ echo -e 'xx\cyy'
xxunicorn:~$
I'm not sure whether the original SysV echo does the same.
Reply to: