I am writing bash script for first time . I have to use nested for loop. I have an array like this:
(foo,bar a,b)
There are two elements in the array and each element in array is separated by commas. I want each element in array to split and print each element. The final result I want is
foo
bar
a
b
I am using nested for loop as below but I am not getting any response
IFS=','
echo "class names is::${classNames[@]}" // prints foo,bar a,b
for ((n=0;n<${#classNames[@]};n++)){
classes=${classNames[n]}
for ((i=0;n<${#classes[@]};i++)){
echo "${eachClass[i]}"
}
}
IFS=','aaaand where doesIFScount?