I am trying to define members of a server cluster minus the machine this script is running on. The "/servers" file is a dynamic file that is controlled by an application. Cluster members are at the very bottom of the file in this format: host1.domain.com https://host1.domain.com:444
I have this snippet from a different script that asks for all of the cluster members. It gives me the servers in their FQDN format. What I want to do is have my output exclude the current machine. How can I make it search the "/servers" file and display the cluster members != $hostname, so to speak?
# !/bin/bash
CLUSTER=$(awk '{ print $1 }' /servers | grep domain.com)
awk can do what grep does, so build that in:
CLUSTER=$(
awk -v hostname=$(hostname) -v domain="domain.com" '
$1 ~ domain && $1 !~ hostname {print $1}
' /servers
)