Quick and Dirty Sed Replace Command

Prodshot_170x190 Had to move my corporate kickstart server to a new vlan and re-ip it this past week. As a result I needed to update my kickstart config files so that they know where to look for the install media. Instead of editing each file directly I did the following to change the IP address in a kickstart config

sed -i ‘s/10.100.x.x/10.1.x.x/g’ centos5-u4_x86_64.cfg.

Once I saw that the command above worked as anticipated, I then ran the same command but on each cfg file in the directory. Syntax below

find . -type f -exec sed -i ‘s/10.100.x.x/10.1.x.x/g’ {} \;

Advertisements

One thought on “Quick and Dirty Sed Replace Command

  1. you can also do that with shell globs, e.g.:
    sed -i ‘s/10.100.x.x/10.1.x.x/g’ *.xml
    or:
    sed -i ‘s/10.100.x.x/10.1.x.x/g’ {some,other}[0-9].conf
    then again find is more versatile and lets you descend into directories and whatnot.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.