Say I have a bash array (e.g. the array of all parameters) and want to delete all parameters matching a certain pattern or alternatively copy all remaining elements to a new
Here's a way using grep:
(IFS=$'\n' && echo "${MY_ARR[*]}") | grep '[^.]*.pattern/[^.]*.txt'
The meat here is that IFS=$'\n'
causes "${MY_ARR[*]}"
to expand with newlines separating the items, so it can be piped through grep.
In particular, this will handle spaces embedded inside the items of the array.