Suppose I have a Unix shell variable as below
variable=abc,def,ghij
I want to extract all the values (abc
, def
and ghij
) using a for loop and pass each value into a procedure.
The script should allow extracting arbitrary number of comma-separated values from $variable
.
Another solution not using IFS and still preserving the spaces: