Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How to replace text within 600+ files.

Discussion in 'General Discussion' started by nat, Jul 26, 2004.

  1. nat

    nat Well-Known Member

    Joined:
    Jan 16, 2003
    Messages:
    210
    Likes Received:
    0
    Trophy Points:
    166
    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. easyhttp

    easyhttp Active Member

    Joined:
    Dec 25, 2003
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Middle East - Jordan
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. nat

    nat Well-Known Member

    Joined:
    Jan 16, 2003
    Messages:
    210
    Likes Received:
    0
    Trophy Points:
    166
    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
     
    #3 nat, Jul 26, 2004
    Last edited: Jul 26, 2004
  4. zentity

    zentity Well-Known Member

    Joined:
    Jun 16, 2004
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    156
    Another way to add to the mix

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

    :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. howudoin321

    howudoin321 Registered

    Joined:
    Nov 25, 2003
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    151
    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>
     
    #5 howudoin321, Aug 1, 2004
    Last edited: Aug 1, 2004
  6. zentity

    zentity Well-Known Member

    Joined:
    Jun 16, 2004
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    156
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. goodmove

    goodmove Well-Known Member

    Joined:
    May 12, 2003
    Messages:
    623
    Likes Received:
    1
    Trophy Points:
    168
    You will also need to increment the serial number in each zone file so the root nameservers can receive the new data.
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice