Skip to content

Instantly share code, notes, and snippets.

@chanslor
Created October 19, 2017 15:34
Show Gist options
  • Save chanslor/af706fa1d1e519b44e3be83d1dc9594c to your computer and use it in GitHub Desktop.
Save chanslor/af706fa1d1e519b44e3be83d1dc9594c to your computer and use it in GitHub Desktop.
Taking semi colon delimited args in for loop
#!/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