Skip to content

Instantly share code, notes, and snippets.

@odellt
Created November 1, 2019 10:21
Show Gist options
  • Save odellt/f0cab0d0df51dfebec35e02e6b8a8d77 to your computer and use it in GitHub Desktop.
Save odellt/f0cab0d0df51dfebec35e02e6b8a8d77 to your computer and use it in GitHub Desktop.
Splits a comma delimited string into an array
#!/bin/bash
#
# Script to split a string based on the delimiter
input_string=$1
IFS=$2 read -ra string_split <<< "$input_string"
#Print the split string
for i in "${string_split[@]}"
do
echo "|$i|"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment