[ad_1]
grep -oP '^server\s\K[^ ]+|^[^#]\s+\d+:\K[^:]+' inputfile
pool0
server1
server2
pool1
server3
server4
4
[ad_2]
solved Extract specific string between two strings and list the required content
[ad_1]
grep -oP '^server\s\K[^ ]+|^[^#]\s+\d+:\K[^:]+' inputfile
pool0
server1
server2
pool1
server3
server4
4
[ad_2]
solved Extract specific string between two strings and list the required content