how to find the block name in which the string available ?
server.conf file
server_pool odd {
0:server1:yes:profile_server1:192.168.1.1,192.168.1.2;
1:server3:yes:profile_server3:192.168.1.5,192.168.1.6;
}
server_pool even {
0:server2:yes:profile_server2:192.168.1.3,192.168.1.4;
1:server4:yes:profile_server4:192.168.1.7,192.168.1.8;
}
#server_pool even {
# 0:server1:yes:profile_server1:192.168.1.1,192.168.1.2;
# 1:server3:yes:profile_server3:192.168.1.5,192.168.1.6;
#}
Notes:-
- "server_pool" is a static string
- "pool_name" can be any string without spaces
- "if a line has # in it ignore it
Requirement
- Need to find the "pool_name" by the provided server hostname as input i.e server{1,2,3,} and store it in a variable
for example
if need to find server1 belongs to which block/ stanza. in the given use case it belongs to odd, so store variable as POOLNAME=odd
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…