replace string
Yong Huang
yong321 at yahoo.com
Sat Oct 25 20:13:04 UTC 2008
> From: "Mad Unix" <madunix at gmail.com>
>
> i need your feedback about this command, it should find a
> string in
> multiple html files in a directory and replace it with a
> different
> string...
>
> find /dir -name "*.html" -exec sed i 's/"old"/"new"/g' {} \;
>
> Thx.
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.
Perl's in-place edit helps in your case:
find /dir -name "*.html" -exec perl -pi -e 's/old/new/g' {} \;
Yong Huang
More information about the redhat-list
mailing list