How to filter a bash array
<p>Suppose I have a bash array</p>
<pre><code>X=(&quot;a&quot; &quot;b c&quot; &quot;-d&quot; &quot;k j&quot;, &quot;-f&quot;)
</code></pre>
<p>I want to filter by whether starting with <code>&quot;-&quot;</code> and get
<code>(&quot;a&quot; &quot;b c&quot; &quot;k j&quot;)</code> and <code>(&quot;-d&quot; &quot;-f&quot;)</code> respectively.</p>
<p>How can I achieve that?</p>