Linux/Solaris replace hostnames in files according to hostname rule
        Posted  
        
            by 
                yael
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by yael
        
        
        
        Published on 2012-12-10T11:00:55Z
        Indexed on 
            2012/12/10
            11:09 UTC
        
        
        Read the original article
        Hit count: 213
        
According to the following Perl command
( this command part of ksh script )
I can replaced old hostnames with new hostnames in Linux or Solaris
 previos_machine_name=linux1a
 new_machine_name=Red_Hat_linux1a
 export previos_machine_name
 export new_machine_name
.
      perl -i -pe 'next if /^ *#/; s/(\b|[[:^alnum:]])$ENV{previos_machine_name}(\b|[[:^alnum:]])/$1$ENV{new_machine_name}$2/g'  file
EXPLAIN: according to perl command - we not replaces hostnames on the follwoing case:
RULE: [NUMBERS]||[letter]HOSTNAME[NUMBERS]||[letter]
my question
after I used the Perl command in order to replace all old hostnames with new hostnames based on the "RULE" in the Perl command
how to verify that the old hostnames not exist in file ?
for example
   previos_machine_name=linux1a
   new_machine_name=Red_Hat_linux1a
   more file
   AAARed_Hat_linux1a          verification should be ignore from this line
   @Red_Hat_linux1a$             verification should be match this line
   P=Red_Hat_linux1a            verification should be match this line
   XXXRed_Hat_linux1aZZZ         verification should be ignore from this line
   .
   .
   .
   .
        © Server Fault or respective owner