For some reason this script is not adding new lines. It prints - 2 - 2 - 2
all on one line even though there is a line break in my variable assignment. I am using bash on mac.
config="1,2,3
1,2,3
1,2,3
"
docker_volumes=""
IFS=$'\n'
for line in $config; do
docker_volume=$(echo "$line" | cut -f 2 -d ',')
# the line break below is being ignored
docker_volumes="$docker_volumes
- $docker_volume"
done
# prints all on one line
echo $docker_volumes