Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2010

    Find / Replace ssh command for dns zones?

    I need to do a quick find/replace for all dns zones in /var/named that have serial 2011061000 and replace it with 2011061300

    and also replace with

    How can I do this?

    $TTL 86400        IN      SOA (
                                    2011061300      ; Serial
                                    7200 ; Refresh
                                    7200 ; Retry
                                    1209600 ; Expire 2 weeks
                                    86400 ) ; Minimum 24 hours
    $GENERATE 2-254 $   NS
    $GENERATE 2-254 $   NS
    [email protected] [/var/named]# named-checkzone xxx.32.32.db   
    zone has no NS records
    Last edited by The Calling; 06-13-2011 at 03:47 PM.

  2. #2
    Join Date
    Feb 2004

    You could try this..

    find ./ -type f -exec sed -i ’s/string1/string2/’ {} \;

    Please make a backup before running this script, as I dont want you blaming me if it goes wrong


  3. #3
    Join Date
    Sep 2010
    I have no idea what that means. I see nothing in that command regarding serial or nameserver domain.

  4. #4
    Join Date
    Jun 2011
    You can make use of the replace command to have this done by running the below script within the /var/named folder

    for file in `grep -rl 2011061000 ./`;do replace '2011061000' '2011061300' -- $file;done

  5. #5
    find ./ -type f -exec sed -i ’s/string1/string2/’ {} \;

    the find finds files in the current directory (./), then invokes sed with the -i (in place replacement) flag. . .

    The simpler way to do this is the sed command with this format:

    sed -i ’s/string1/string2/g’ *.*

    replace string1 with the string you want to replace, taking care to escape characters (by putting a \ in front of them) that would be reserved in regular expressions, like / and . Note that the *.* means that all files in the current directory would be affected, you can use the filters you want to affect the files you want. replace string2 with the new string, and you don't have to escape those chatacters.

    It's a good idea to backup the files 1st, and then practice a bit. .

  6. #6
    You can search on google "ssh find and replace" and there're great samples

Similar Threads

  1. Find SSH Command
    By Lost Eagle in forum Hosting Security and Technology
    Replies: 10
    Last Post: 03-27-2011, 05:45 PM
  2. SSh command to find out the plesk version
    By anastasia0181 in forum Web Hosting
    Replies: 2
    Last Post: 09-09-2009, 10:10 AM
  3. Command line find and replace?
    By acctman in forum Programming Discussion
    Replies: 9
    Last Post: 10-03-2008, 04:41 PM
  4. Replies: 8
    Last Post: 02-03-2005, 12:39 AM
  5. How to create DNS zones in Win NT from command line
    By mac in forum Hosting Security and Technology
    Replies: 8
    Last Post: 11-27-2000, 12:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts