We can use an internal field separator (IFS) variable to parse an array. Let’s use an example script, where first we define a string with colon-separated. Then we will use IFS to separate values based on a delimiter.
Let’s execute this script and check for results.
./myscript.sh
Output:orange grapes banana apple
2 Comments
Uugh, nothing works for me.
$ IFS=’;’ read -ra NAMES <<< "$STR"
syntax error: `<' unexpected
Its working for me thanks for the post