Skip to content

Instantly share code, notes, and snippets.

@srkiNZ84
Created January 7, 2019 03:35
Show Gist options
  • Save srkiNZ84/139d10e0b962a2bbc87e948142a05326 to your computer and use it in GitHub Desktop.
Save srkiNZ84/139d10e0b962a2bbc87e948142a05326 to your computer and use it in GitHub Desktop.
comma_separated_list_to_array.sh
#!/bin/bash
CITIES="Paris, Madrid, Berlin"
IFS=', ' read -r -a citiesArray <<< "$CITIES"
for city in "${citiesArray[@]}"
do
echo "City: $city"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment