bug-sed
[Top][All Lists]
Advanced

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

bug#50701: cannot append or insert to empty file or stream


From: Davide Brini
Subject: bug#50701: cannot append or insert to empty file or stream
Date: Mon, 20 Sep 2021 21:40:19 +0200

On Mon, 20 Sep 2021 10:53:48 +0200, lexi hale <lexi@hale.su> wrote:

> there is an inconsistency in the handling of the a and i commands in
> sed. if the input stream or file immediately yields EOL, sed ignores
> the commands and produces an empty stream.
>
> for instance:
>
>       $ echo -n >file line-1
>       $ sed -i aline-2 file
>       $ cat file
>
> correctly yields
>
>       line-1
>       line-2
>
> however,
>
>       $ touch empty
>       $ sed -i aline-1 empty
>       $ cat empty
>
> prints nothing,  instead of the expected result "line-1".

It's the same thing as the following:

$ echo x > file
$ sed -i 's|^|FOO|' file
$ cat file
FOOx

$ touch empty
$ sed -i 's|^|FOO|' empty
$ cat empty
$

Would you expect a line magically materializing in the seocnd case? I
suppose you wouldn't...

--
D.





reply via email to

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