I am need to extract a number of values from a file, put have now clue how to do this.
The file looks like this:
# My file
Dest=87;CompatibleSystemSoftwareVersion=2.5300-;
Dest=87;ImageVersion=000061f3;SystemSoftwareVersion=2.5300;CDN=http://my.backup.com/download.txt;CDN_Timeout=30;
I would like to extract the value for SystemSoftwareVersion and CDN into two variables as part of a bash-script so that I can use them further.
Not sure if that is what you need. Maybe it's better to load them in an array so you can work them if they form up a pair, ie. are associated each other or something like that.
Thanks this is brilliant - I had to make some minor adjustments, but now is exactly what I need:
CURR_FIRMWARE=`sed -n 's/.*;SystemSoftwareVersion=\([^;]*\);./\1/p' ${PS3_VERSION_FILE}`
CURR_URL=`sed -n 's/.*;CDN=\([^;]*\);./\1/p' ${PS3_VERSION_FILE}`
below script should be able to find any number inside your file, you may need to modify it to address your requirement.
open FH,"<a.txt";
while(<FH>){
tr/\n//d;
my @tmp=split(";",$_);
foreach(@tmp){
print "Var[$1]: $2\n" if (m/(.*)=([0-9][0-9]*\.*[0-9][0-9]*)/);
}
}
close FH;