Created
October 19, 2017 15:34
-
-
Save chanslor/af706fa1d1e519b44e3be83d1dc9594c to your computer and use it in GitHub Desktop.
Taking semi colon delimited args in for loop
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 | |
#STR="Sarah;Lisa;Jack;Rahul;Johnson" #String with names | |
STR=$(cat users.txt) | |
if [ -z $STR ] ; then | |
echo "STR is not set." | |
exit 1 | |
fi | |
IFS=';' read -ra NAMES <<< "$STR" #Convert string to array | |
#Print all names from array | |
for i in "${NAMES[@]}"; do | |
echo $i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment