Created
September 28, 2019 01:01
-
-
Save petronetto/fc07037cded8d4243b02791bee41ce74 to your computer and use it in GitHub Desktop.
Bash Split String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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