Imagine I created an array like this:
IFS="|" read -ra ARR <<< "zero|one|||four"
now
echo ${#ARR[@]}
> 5
echo "${ARR[@]}"
> zero one four
echo "${ARR[0]}"
> zero
echo "${ARR[2]}"
> # Nothing, because it is empty
The question is how can I replace the empty elements with another string?
I have tried
${ARR[@]///other}
${ARR[@]//""/other}
none of them worked.
I want this as output:
zero one other other four