Subject: -i and -n options are order-sensitive

From: rgrosso <[email-masked]>
Date: Thu, 25 Mar 2021 10:41:51 +0100

Hi,

To remove the first N lines from a big text file I used to do:

sed -in '1,Nd' bigfile.txt

and it was working as expected. Assuming the order of the flags does not 
matter I did once:

sed -ni '1,Nd' bigfile.txt

which deleted the whole content of the file. Is this behaviour expected? 
From the user point of view this seems like a rather dangerous bug. I 
think, flags not taking an argument should be insensitive to the order.

Currently, to get the same result without running the risk to forget the 
right order of the flags and deleting the file content, I do:

sed -i -e '1,Nd' bigfile.txt

(Using GNU sed 4.4 or 4.8)

Cheers,

    Raffaele