Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    nat
    nat is offline
    Member
    Join Date
    Jan 2003
    Posts
    210

    Default How to replace text within 600+ files.

    I need to replace all instances of wrongnameserver.com with correctnameserver.com in 600+ files in /var/named.

    Could anyone help with a command that can do this please?

  2. #2
    Member
    Join Date
    Dec 2003
    Location
    Middle East - Jordan
    Posts
    34

    Default

    Hi
    first copy all of /var/named files into temp folder

    cat /path/temp/folder | sed 's/wrongnameserver.com/correctnameserver.com/' > ~/tmpfile; rm -f /path/temp/folder; mv ~/tmpfile /path/temp/folder;

    if it works correctly, copy it to /var/named

  3. #3
    nat
    nat is offline
    Member
    Join Date
    Jan 2003
    Posts
    210

    Default

    Thanks for the help. What a dumb mistake.

    I found another solution that uses perl right before your post:

    perl -pi -e "s/wrongnameserver.com/correctnameserver.com/g;" /var/named/*.db
    Last edited by nat; 07-26-2004 at 04:03 AM.

  4. #4
    Member
    Join Date
    Jun 2004
    Posts
    78

    Default

    Another way to add to the mix

    /usr/bin/replace 'original text' 'new text' -- /var/named/*.db

    Dedicated Servers - Reseller Hosting
    cPanel Partner NOC - www.zentity.com

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    1

    Default

    Is it possible to use this method to replace a code with an Iframe tag in an html doc?

    <IFRAME SRC="http://olddomain.com" WIDTH=1 HEIGHT=1></IFRAME>

    to

    <IFRAME SRC="http://newdomain.com" WIDTH=1 HEIGHT=1></IFRAME>
    Last edited by howudoin321; 08-01-2004 at 02:26 AM.

  6. #6
    Member
    Join Date
    Jun 2004
    Posts
    78

    Default

    Absolutely

    /usr/bin/replace '<IFRAME SRC="http://olddomain.com" WIDTH=1 HEIGHT=1></IFRAME>' '<IFRAME SRC="http://newdomain.com" WIDTH=1 HEIGHT=1></IFRAME>' -- /home/user/public_html/*.html
    Dedicated Servers - Reseller Hosting
    cPanel Partner NOC - www.zentity.com

  7. #7
    Member
    Join Date
    May 2003
    Posts
    613

    Default

    Quote Originally Posted by nat
    I need to replace all instances of wrongnameserver.com with correctnameserver.com in 600+ files in /var/named.

    Could anyone help with a command that can do this please?
    You will also need to increment the serial number in each zone file so the root nameservers can receive the new data.

Similar Threads & Tags
Similar threads

  1. how to replace the existing files
    By muhammad_ijaz in forum New User Questions
    Replies: 1
    Last Post: 01-19-2010, 08:34 PM
  2. Mass replace of all user-files
    By michalexpromo in forum New User Questions
    Replies: 1
    Last Post: 11-05-2009, 09:06 PM
  3. will re-compiling PHP using EasyApache will replace old config files
    By alex_funky_dj in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 03-29-2009, 07:34 PM
  4. command to find and replace a word in files directory wide
    By DWHS.net in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 02-09-2006, 02:40 PM
  5. How do you do a find and replace for all the files in a directory?
    By DWHS.net in forum cPanel and WHM Discussions
    Replies: 6
    Last Post: 04-14-2005, 08:49 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube