I have a file with Server and Domain names in it as below.
Names.txt :
ABCDomain ContractABCServer_1 ABCDomain ABC_server1 LinkDomain CoreLinkServer_1 TADDomain TADServer_1
(I'm getting above file after performing sort and unique operations to some other file.)---just additional info
I need to extract values from above file and pass it to a xyz command (the command is used to restart servers) as a parameter in below format.
O/P:
"ABCDomain(server:ContractABCServer_1,server:ABC_server1)","LinkDomain(server:CoreLinkServer_1)","TADDomain(TADServer_1)"
I m using below stated logic, but it doesn't give me the desired output as the DomainName has to come just once for each set. Also I m having trouble in keeping the same line.
-----------START------
DOMAIN='' IFS=' ' while read line do DOMAIN=$(echo "$line" | awk -F " " '{print $1}') for word in $line do if [[ "$word" == "$DOMAIN" ]]; then Server=$(echo "$line" | awk -F " " '{print $2}' ) echo -n "(server:$ServerName" fi done done < Names.txt