3 ms·
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 targe
by 1vuio0pswjnm7 4y ago
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
- 1vuio0pswjnm7 4y agoInstead 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.