These are some of the programs I've written or contributed to that I can recall right now.
$ ls -l lifeswork.c -rw-r--r-- 1 user group 3582956 Nov 20 14:40 lifeswork.c $ sed -e s/$badcode/$goodcode/ lifeswork.c >lifeswork.c $ cat lifeswork.c $ ls -l lifeswork.c -rw-r--r-- 1 user group 0 Nov 20 14:40 lifeswork.c $ @$%$^ bash: @$%$^: command not found $ :(With owrite, you can avoid this heartache.
$ owrite lifeswork.c sed -e s/$badcode/$goodcode/When you use output redirection, the Unix shell immediately opens the file for writing. This necessitates using a temporary file if the input and output files are the same. owrite simply automates the process.
I have only tested this shell program with bash, but it might work with other Bourne or Bourne-style shells. If it does for you, please let me know so I can note that here.
Credit is given to Brian W. Kernighan and Robert Pike for The UNIX Programming Environment. This program is based on an example I remember from that book.
Valid HTML hand-coded by bill@billjonas.com
Last modified Sat Mar 1 09:17:59 MST 2003