3 ms·
If you want to perform an in-place edit, and you want to do it in a portable manner (not using GNU sed -i), you'd have to use sed with at least one temporary fi
by Annatar 10y ago
If you want to perform an in-place edit, and you want to do it in a portable manner (not using GNU sed -i), you'd have to use sed with at least one temporary file:
% sed -e 's/something/other/' somefile > /tmp/temp.$$ && mv /tmp/temp.$$ somefile
now, using ed (or AWK) and the heredoc with ed commands above, you can mmap(2) the entire file into memory, perform desired editting, and write it all out in one go. No more temporary files!