Sponsored Content
Full Discussion: NEED HELP
Top Forums Shell Programming and Scripting NEED HELP Post 302429855 by haiksuresh on Tuesday 15th of June 2010 09:45:08 PM
Old 06-15-2010
Quote:
Originally Posted by aster007
Try this

Code:
TEMP_VAR=`find . -type f -iname "*xml*"`

echo $TEMP_VAR | while read X
do
    cat $X | grep "MIG_Host"
    
    if [[ $? -eq 0 ]];
    then
        cat $X | sed "s/217.171.101.225/100.100.100.100/g" > temp_file
        chmod 777 $X
        cat temp_file > $X
        rm -f temp_file
    fi
done

Thats fine, But my input file may contain somany parameters all should need to be searched and replaced in all xml files. Here we have hard coded the values in the code. Please help me.

---------- Post updated at 08:45 PM ---------- Previous update was at 08:44 PM ----------

Quote:
Originally Posted by pseudocoder
Maybe this?
Code:
$ perl -pi.bak -e 'if ($a == 1) { $_ =~ s/>.*</>100\.100\.100\.100</ ; $a=0;}
                   if ($a == 2) { $_ =~ s/>.*</>8080</ ; $a=0;}
                   $a=1 if $_ =~ /MIG_Host/;
                   $a=2 if $_ =~ /MIG_Port/;
                  ' *.xml

or
Code:
$ perl -pi.bak -e 'if ($a == 1) { $_ =~ s/>.*</>100\.100\.100\.100</ ; $a=0;} $a=1 if $_ =~ /MIG_Host/;' *.xml

if you want to change only the ip.
Thats fine, But my input file may contain somany parameters all should need to be searched and replaced in all xml files. Here we have hard coded the values in the code. Please help me.
 
MUSETUP(1)							Museek Daemon Plus							MUSETUP(1)

NAME
Musetup - Configuration script for Museekd SYNOPSIS
musetup <config-filename> [-h] [--help] DESCRIPTION
Musetup is command-line Python script that configures museekd(1). Configuration options are selected by entering one of the numbers dis- played. Modifying those options are done by choosing an option's number or by inputing text. OPTIONS
Musetup accepts the following options: <config-filename> Selected Config's path and filename. -h, --help Display Help and exit. EXAMPLE
To run this program the standard way type: musetup Alternativly you use a different config file with: musetup config.xml FILES
~/.museekd/config.xml The default location for the museekd config file. /usr/share/museek/museekd/config.xml.tmpl Config file template that's used if no config exists. AUTHORS
Hyriand <hyriand@thegraveyard.org> daelstorm <daelstorm@gmail.com> SEE ALSO
mucous(1) mulog(1) murmur(1) muscan(1) muscand(1) museekcontrol(1) museekd(1) museeq(1) musetup-gtk(1) daelstorm Release 0.2.0 MUSETUP(1)
All times are GMT -4. The time now is 06:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy