Assume that, you want to find and replace a specific word in a file can use sed command,
For example i would like to changed sample.com. instead of mail.sample.com
Displaying output only, without string update
sed s/mail.sample.com/sample.com./g /var/named/domain.com.db
To update the string,
-i is replaces the word
sed -i s/mail.sample.com/sample.com./g /var/named/domain.com.db
A hole line you want to find and replace
sed -i 's/ns1.sample.com. 14400 IN A 192.168.0.100/ns2.sample.com 7200 IN A 192.168.0.1/g' /var/named/*.*.db
Can be update all files under the directory of /var/named/
sed -i 's/ns1.sample.com. 14400 IN A 192.168.0.100/ns2.sample.com 7200 IN A 192.168.0.1/g' /var/named/*
Comments (0)