[YLUG] How do to substition in a file with sed or similar
Charles Forsyth
forsyth at terzarima.net
Sat Oct 28 10:30:20 BST 2006
>> see the `overwrite' command in Kernighan and Pike:
>> and it's useful for tr and commands with similar interfaces
>
> alternatively you can use the -i flag for GNU sed (but only GNU).
and only those other commands to which the option has been added.
tr for instance, does not provide it.
or of course, one could add the option to each command in turn as it's found to be useful.
the advantage of overwrite (and taking a similar approach to similar problems) is that
it composes with the existing ones without changing them: without adding complexity
not just to their interfaces, but their implementations. for instance, tr is a simple filter; to support
the same -i it would need to maintain a temporary copy of its output, just for that option.
in fact, much the same is true of sed.
anyhow, there are a few other examples of that in the book.
More information about the York
mailing list