In Bash, when you open a file for writing, the file gets truncated.However, there is a way to open a file for both reading and writing atthe same time. Who hasn’t made the mistake of creating a process that tries to bothread and write to the same file? $ wc -c file17 file$ sed s/foo/FOO/ <file >file$ wc -c file0 Oops. That’s why for sed(1) in particular you use the-i[SUFFIX], --in-place[=SUFFIX] switch, and in general can usesponge(1) from moreutils (e.g. grep foo <file | sponge >file). B...