Saturday 24 July 2021

Concatenate inputs in string while in loop

 SOURCES="a b c d e"

DESTINATIONS=""

for src in $SOURCES
do
    echo Input destination to associate to the source $src:
    read dest
    DESTINATIONS+=" ${dest}"
done
echo $DESTINATIONS


from: https://stackoverflow.com/questions/42934198/concatenate-inputs-in-string-while-in-loop

How to split a list by comma not space

sorin@sorin:~$ IFS=',' ;for i in `echo "Hello,World,Questions,Answers,bash shell,script"`; do echo $i; done
Hello
World
Questions
Answers
bash shell
script 

sorin@sorin:~$  


from: https://stackoverflow.com/questions/7718307/how-to-split-a-list-by-comma-not-space