News for hackers. Stuff that matters.
Re:Actually using Ed by 1vuio0pswjnm7 on Saturday December 31, 2022 @09:40PM (#34203041)
Turns out this was mentioned on StackOverflow in 2017.

Here is a sed solution

   sed -i -e1r/dev/stdin -e1N $1
However this still has a limitation. The target file must be more than one line.

Using a named pipe for large files

   test -s 1.fifo||mkfifo 1.fifo

   cat largefile > 1.fifo &

   printf '0r 1.fifo\nw\nq\n'|ed -s $1

   curl -A "" -4o 1.fifo https://example.com/largefile.gz &

   gzip -dc largefile.gz|tail -100|sed -i -e 1r/dev/stdin -e1N $1
Re:Actually using Ed by 1vuio0pswjnm7 on Wednesday January 11, 2023 @04:50PM (#34345450)
Instead of sed -i, one can use ired.

   od -tx1 -An|sed 's/^/w /'|ired -n $1 /dev/stdin
Unless I am mistaken, ired does not use a temp file, unlike sed -i.