[lug] easy sed question...

Harris, James James_Harris at maxtor.com
Mon Feb 12 16:50:28 MST 2001


Howdie!
I'm sure this is extremely simple, but I can't seem to find anything on it:
How can I tell sed to be case insensitive with the patterns it's matching?
Some of the zone files I'm manipulating have case inconsistencies and my
script isn't cathing all that it needs to.  (Since it's DNS, the case hasn't
mattered, but we're trying to get things cleaned up in the process...)  I
don't want to have to come up with ten pattern searches unless I _really_
have to (I figure there's gotta be a better way.)

Here's my script:
#!/bin/bash
# DNS update -- changes legacy NS records for dns2.maxtor.com.
# to dns2.mlm.maxtor.com. in the zone files.  It also adds a new NS
# record for the new DNS server to each of the zone files.

for x in *
  do
    echo Processing $x"..."
    sed '/NS/s/dns2.maxtor.com./dns2.mlm.maxtor.com./1' $x | \
    sed '/NS/{ /dns2.mlm.maxtor.com./a\
                IN      NS      mlmns01.mlm.maxtor.com.
    }' > ./new/$x
done

Thanks whole bunches!!
Jim Harris



More information about the LUG mailing list