Searching a delimited Key value pairs in shell script

Hello,

I have property file with key value pairs separated by pipe , I am trying to write a script which reads the property file and search and print value of specific key. I tried with Sed, I am successfull.

The file is as follows

SVR_NAME=server-1|SVR_DOMAIN=CELLDUMMY|SVR_HOST=server-1.tst.com|SVR_LISTENPORT=5000|SVR_VERSION=10.6

SVR_NAME=server-2|SVR_DOMAIN=CELLDUMMY|SVR_HOST=server-2.tst.com|SVR_LISTENPORT=5000|SVR_VERSION=10.6

let 's say I need to search SVR_HOST and print the value of SVR_HOST for server-2 (which is server-2.tst.com) . How can I do the in the script.

I tried to first search a line containing server-2 ,but not able to print "server-2.tst.com",it priniting whole line or priting SVR_NAME=server-2,I know I am doing mistake in trimming. I am not sure how to fix it.. Could you please help me on this ?

I am trying to write the script in UNIX,looking for shell script

Thanks,
ANK

$ ruby -F"\|" -ane 'puts $F[2] if $F[0] =~ /^.*server-2$/' file
SVR_HOST=server-2.tst.com

yes

awk 'BEGIN{RS="|";FS="="} /SVR_HOST/ {print $2}' infile

server-1.tst.com
server-2.tst.com