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’ {} \;

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.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s