replace string

Yong Huang yong321 at yahoo.com
Sun Oct 26 01:05:30 UTC 2008


--- On Sat, 10/25/08, Cameron Simpson <cs at zip.com.au> wrote:

> From: Cameron Simpson <cs at zip.com.au>
> Subject: Re: replace string
> To: yong321 at yahoo.com, "General Red Hat Linux discussion list" <redhat-list at redhat.com>
> Date: Saturday, October 25, 2008, 7:33 PM
> On 25Oct2008 13:13, 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, which does the
> same kind of thing as
> Perl's -i (in place edit) option, with the same
> often-undesirable hard link
> breakage.
> -- 
> Cameron Simpson <cs at zip.com.au>

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.

Yong Huang


      




More information about the redhat-list mailing list