I am using following script, which uses case statement to find the server.
#!/bin/bash
SERVER=$1;
echo $SERVER | egrep "ws-[0-9]+.host.com";
case $SERVER in
ws-[0-9]+.host.com) echo "Web Server"
;;
db-[0-9]+.host.com) echo "DB server"
;;
bk-[0-9]+.host.com) echo "Backup server"
;;
*)echo "Unknown server"
;;
esac
But it is not working. Regex is working with egrep but not with case. sample O/P
./test-back.sh ws-23.host.com
ws-23.host.com
Unknown server
Any Idea ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…