bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed : * final newline


From: Stepan Kasal
Subject: Re: sed : * final newline
Date: Mon, 7 Jul 2003 19:22:04 +0200
User-agent: Mutt/1.2.5.1i

Hello,

On Sat, Jul 05, 2003 at 02:38:40PM +0800, Dan Jacobson wrote:
> Each file is one line, with no newline at the end of line.
> $ ls|wc
>     259     259    6216
> $ sed : *|wc
>     258     259   15947
> $ awk 1 *|wc
>     259     259   15948
> Sed appends a newline to all but the last file.

current GNU sed (4.0.6) seems to contain a hack to append the newline
to the output line only if it was there originally.
This is probably done because it would be nice if "sed :" would not
modify the input file.

This has weird consequences, watch:

address@hidden sed-4.0.6]$ sed/sed -n 'p;p' one two
one
one
address@hidden sed-4.0.6]$

This behaviour also violates POSIX, as it clearly states that:
"Whenever the pattern space is written to standard output or a named
file, sed shall immediately follow it with a <newline>."

So I would gave up the attempts to keep the info whether
the newline was there---it must strike back one way or another.

Paolo, would you agree with me?

Looking forward to your answer,
        Stepan Kasal




reply via email to

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