title: Shell parameter expansion on arrays
body: <p>Say I read some data into a Bash array:</p>
  
  <pre><code>$ IFS=" " read -a arr &lt;&lt;&lt; "hello/how are/you iam/fine/yeah"
  </code></pre>
  
  <p>Now, I want to print the first <code>/</code>-sliced field for each element in the array.</p>
  
  <p>What I do is to loop over the elements and use shell parameter expansion to strip everything from the first <code>/</code>:</p>
  
  <pre><code>$ for w in "${arr[@]}"; do echo "${w%%/*}"; done
  hello
  are
  iam
  </code></pre>
  
  <p>However, since <code>printf</code> allows us to print the whole content of the array in a single expression:</p>
  
  <pre><code>$ printf "%s\n" "${arr[@]}"
  hello/how
  are/you
  iam/fine
  </code></pre>
  
  <p>... I wonder if there is a way to use the shell parameter expansion <code>${w%%/*}</code> at the time of using <code>printf</code>, instead of looping over all the elements and doing it against every single one.</p>