I am looking to append each element of a bash array with |
except the last one.
array=("element1" "element2" "element3")
My desired output would be
array=("element1"|"element2"|"element3")
What I have done
for i in ${!array[@]};
do
array1+=( "${array[$i]}|" )
done
Followed by
array=echo ${array1[@]}|sed 's/|$//'
Is there any other looping approach I can use that only appends the character until the last but one element?