Hacker News new | ask | show | jobs
by charliesome 2127 days ago
Re sponge: the shell will open the output file for writing before invoking the command so in the example joey provides, /etc/passwd will be an empty file by the time sed opens it.
2 comments

heh, yeah that's a mistake everyone makes once, and hopefully not more than once.
That makes sense but in the example provided, why can't we use sed with the in-line flag?
Because the -i flag works differently on GNU sed vs non-GNU sed and there is no way to use it portably.