From: Chris Koeritz Date: Mon, 30 Sep 2013 01:24:54 +0000 (-0500) Subject: new example for bash. X-Git-Tag: 2.140.90~916 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=ab8bae17785ff437d4758f1fb123e2b544b4ca2e;p=feisty_meow.git new example for bash. --- diff --git a/examples/bashisms/comma_separated_string_to_array.sh b/examples/bashisms/comma_separated_string_to_array.sh new file mode 100644 index 00000000..64c05b3e --- /dev/null +++ b/examples/bashisms/comma_separated_string_to_array.sh @@ -0,0 +1,12 @@ + + +#taking a comma (or any char) separated list and turning it into an array: + +commaSeparatedList=tony,tiger,detroit,sugar,biscuits + +IFS="," read -ra argArray <<< "$commaSeparatedList" + +for ((i = 0; i < ${#argArray[@]}; i++)); do + echo "arg $(($i + 1)): ${argArray[$i]}" +done +