Basically I'd like to split a string into an array by a string separator like sep. for example.
Is there native bash way to do this without using tools like sed, awk, etc?
I know I can split a string into an array by setting IFS and using read -ra but that doesn't work with string separators. And if there is not how you'd do it with tools like sed, awk, etc?
Let's say I have the string This is some sep.string and I'd like to split it into an array with 2 elements: This is some and string.
foo='a sep b sep c'; s=$'\1'; IFS=$s read -ra <<<"${foo//sep/$s}" array; printf "{%s}\n" "${array[@]}"