> sponge: soak up standard input and write to a file
How does this differ than just redirecting to a file in the shell?
How does this differ than just redirecting to a file in the shell?
echo "hello world" >> dummyfile
cat dummyfile | sed 's/hello/goodbye/' > dummyfile
dummyfile will be blank afterwardsif you do:
cat dummyfile | sed 's/hello/goodbye/' | sponge dummyfile
It'll work as you'd expect (or at least as I'd expect). Otherwise `> dummyfile` will truncate dummyfile before it's read and inputed into sed.AKA
sed -i 's/hello/goodby/' dummyfile
Does the '>' operator blanks the file first, before the read happens?
This isn't the issue.