replace string

Cameron Simpson cs at zip.com.au
Sun Oct 26 03:16:33 UTC 2008


On 25Oct2008 18:05, Yong Huang <yong321 at yahoo.com> wrote:
| > | > From: "Mad Unix" <madunix at gmail.com>
| > | > find /dir -name "*.html" -exec sed i 's/"old"/"new"/g' {} \;
| > | Even if you get your sed command right, that won't do in-place
| > | replacement, because if you use sed, the result has to be saved to a
| > | different file and you mv that file to overwrite your original file.
| > 
| > He is trying to use GNU sed's -i option, [...]
| Thanks, Cameron. My knowledge of sed got stuck at the O'Reilly book
| "sed and awk" and didn't realize the GNU version had many more options. I
| found my book on the shelf. It was published in 1997.

I try to stick to the same usage as you (and, indeed, the same book!)

I just happen to know the GNU sed has some extra stuff because I see
people using it. Personally, I avoid it (extra non-portable features)
unless I really gain a large benefit from it; as soon as you use such
things you are stuck when you go to another system which doesn't use the
GNU tools, and also you start to forget the portable way and write more
and more stuff that doesn't port.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

(about SSSCA) I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy.
- H. Peter Anvin <hpa at hera.kernel.org>




More information about the redhat-list mailing list