$ sed -i '$w/dev/stdout;$d' testFile
sed: couldn't open file /dev/stdout;$d: Permission denied
$
Doesn't that resembles http://bugs.debian.org/620610 ?
Regardless, I am not sure whether one, who is fluent in the sed
language, should be able to predict the outcome of sed -i '$p'. I mean,
where it is defined in which line would the content of the output will
appear in the file?
$ sed -i '$p' testFile
$ cat testFile
1
2
2
$
Why it is not:
2
1
2
? In case you claim that with -i, the seek position of the input
and output files are expected to point to the same location,
subjected to possible previous operations in the script or script-file:
Was I supposed to deduce that from the manual?
--- On Fri, 11/11/11, Paolo Bonzini <[email protected]> wrote:
> From: Paolo Bonzini <[email protected]>
> Subject: Re: Bug#648344: sed -i '$p;$d' doesn't work
> To: "Regid Ichira" <[email protected]>
> Cc: [email protected]
> Date: Friday, November 11, 2011, 9:31 PM
> On 11/11/2011 10:28 PM, Regid Ichira
> wrote:
> > I expected sed -i '$p;$d' to output the
> last line, 2 in this case;
> > and to delete that line from the file.
>
> No, the output of "p" goes directly to the output file even
> with "sed -i". You should use "$w/dev/stdout" instead
> of "$p".
>
> Paolo
>
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]