Answers for "bash tokenize string"

1

bash tokenize string

For any delimiters, like ';'

$ string="john;is;17;years;old"
$ IFS=';' tokens=( $string )
$ echo ${tokens[*]}
Posted by: Guest on October-12-2021
0

bash tokenize string

For Space delimiter

$ string="john is 17 years old"
$ tokens=( $string )
$ echo ${tokens[*]}
Posted by: Guest on October-12-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language