Re: replace string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: "Mad Unix" <madunix@xxxxxxxxx>
> 
> 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


      

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux