Reputation: 172
In bash I got all the names from services which are balanced from /etc/haproxy. But now I want to store all these intro a $srv variable in order to continue my healthcheck script.
for filename in /etc/haproxy/*.cfg; do
for ((i=0; i<=0; i++)); do
srv = $(echo $filename | awk -F'[/.]' '{print $4}')
echo $srv
done
done
Using echo $filename | awk -F'[/.]' '{print $4}' is showing the correct microservices names like: service1 service2 service3
Upvotes: 0
Views: 74
Reputation: 780688
You can't have spaces around the =
in shell variable assignments. What you wrote is trying to run the srv
command, not assign to the srv
variable. It should be:
srv=$(echo $filename | awk -F'[/.]' '{print $4}')
Upvotes: 2