Skip to content

Instantly share code, notes, and snippets.

@petronetto
Created September 28, 2019 01:01
Show Gist options
  • Save petronetto/fc07037cded8d4243b02791bee41ce74 to your computer and use it in GitHub Desktop.
Save petronetto/fc07037cded8d4243b02791bee41ce74 to your computer and use it in GitHub Desktop.
Bash Split String
#!/bin/bash
# usage: split.sh foo,bar
options=($(echo $1 | tr "," "\n"))
for i in "${options[@]}"
do
case $i in
"foo")
echo Foo
;;
"bar")
echo Bar
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment