i have yet another question regarding bash.
in a text file, there is a set of information. the constant here is the "sys app" and the end "checker"
sys app /partition/app_webapps_80 {
load-balancing-mode least-connections-member
members {
/partition/host-1:80 {
address 10.20.20.200
}
/partition/host-2:80 {
address 10.20.20.201
}
}
checker /partition/tcp
}
sys app /partition/app_webapps_8989 {
members {
/partition/host-1:8989 {
address 10.20.20.200
}
/partition/host-2:8989 {
address 10.20.20.201
}
}
checker /partition/tcp
}
what i did is to create a while loop, then i uses the following, however i get the address replicated the number of lines in the file.
line=1
while read do rs=$(sed -n '/sys app/,/checker/p' filename |grep -m $line "address" |tail -n 1)
echo `$rs
line=$[$line +1]`
done < filename
what should i go for, if i just want to match some information in between 2 string, then assign it to a variable that i can use for later?
appreciate any advise on this.
since under app_webapps_80 and app_webapps_8989 they have the same address 10.20.20.200 and address 10.20.20.201
the expected result is to run the loop. and the loop will run to identify how many address there are between app_webapps_80 and the first checker
then assign the address 10.20.20.200 to a variable to use and then assign address 10.20.20.201 to another variable to use
the loop will run again to identify the new app_webapps_8989 and the checker in that section repeat what it does for the first set.
not sure if i make sense on this?