Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash split string into variables

# separator is space
VAR="inforge srl bergamo"
read -r ONE TWO THREE <<< "${VAR}"
echo ${ONE}
echo ${TWO}
echo ${THREE}

# separator is comma
VAR="inforge,srl,bergamo"
IFS="," read -r ONE TWO THREE <<< "${VAR}"
echo "${ONE} ${TWO} ${THREE}"
Source by www.inforge.it #
 
PREVIOUS NEXT
Tagged: #bash #split #string #variables
ADD COMMENT
Topic
Name
3+6 =