I have a list of servers in a file called serverlist like this
server1
server2
server3
i need to have them (with no trailing comma, the program does not like that)
server1,server2,server3
so far i have been using
HOSTS=/tmp/serverlist
HOSTS=${HOSTS:-$(grep -Ev "^#|^$" $HOSTS_LOCAL)}
HOSTS=$(echo $HOSTS |tr -s '\n ' ',,')
HOSTS=${HOSTS%,}
to achieve this. It works but is there a quicker easier way say like in one line. (I need the grep -Ev "^#|^$" because we have a lot and need to comment them out sometimes).
Sean