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 array. Alternatively, the other way round, keep elements matching a pattern.
An example for illustration:
x=(preffoo bar foo prefbaz baz prefbar)
and I want to delete everything starting with pref
in order to get
y=(bar foo baz)
(the order is not relevant)
What if I want the same thing for a list of words separated by whitespace?
x="preffoo bar foo prefbaz baz prefbar"
and again delete everything starting with pref
in order to get
y="bar foo baz"