Making Global Changes with sed

Another handy command you can use is sed, which lets you make multiple changes to files, without ever opening an editor. For example, as a new Webmaster, you might use sed to change all occurrences of the previous Webmaster’s email address to your own. As we’ll show in this section, you can use sed to make global changes within documents.

Code Listing 6.10. You can use sed to make changes throughout files, such as the address change here.
[ejr@hobbes manipulate]$ sed's/oldaddr@raycomm.com/newaddr@raycomm.com /g'address.htm > address-new.htm
[ejr@hobbesmanipulate]$ headaddress-new.htm <BODY BACKGROUND="/images/background.gif" BGCOLOR="#FFFFFF" TEXT="#000000" LINK= "#009900" VLINK="#000000" ALINK="#ff0000"> ...

Get Unix Third Edition: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.