Thanks Matthew,
Matthew Gregan wrote:
The reason this happens is that the shell opens the files for redirection before executing the new process (sed, in this case). The '>' redirection is telling the shell to create a new file, or truncate an existing one, and begin writing to the start of the file. By the time the sed process runs, it's going to be reading input from an empty file and writing it's output (none) to the same empty file.
Assuming you're using a Bourne-like shell (I'd guess you're using bash),
Yes.
you can avoid this by enabling the 'noclobber' shell option, i.e. 'set -o noclobber'.
Now that is clever (protection).
Cheers, -mjg
- Backtracking to decode original the a(ppend)\ option..
Cheers,
- Rik
