title: Converting a Bash array into a delimited string
body: <p>I would like to know the following;</p>
  
  <ol>
  <li>Why the given non-working example doesn't work.</li>
  <li>If there are any other cleaner methods than those given in working example.</li>
  </ol>
  
  <p><em>Non-working example</em></p>
  
  <pre><code>&gt; ids=(1 2 3 4);echo ${ids[*]// /|}
  1 2 3 4
  &gt; ids=(1 2 3 4);echo ${${ids[*]}// /|}
  -bash: ${${ids[*]}// /|}: bad substitution
  &gt; ids=(1 2 3 4);echo ${"${ids[*]}"// /|}
  -bash: ${"${ids[*]}"// /|}: bad substitution
  </code></pre>
  
  <p><em>Working example</em></p>
  
  <pre><code>&gt; ids=(1 2 3 4);id="${ids[@]}";echo ${id// /|}
  1|2|3|4
  &gt; ids=(1 2 3 4); lst=$( IFS='|'; echo "${ids[*]}" ); echo $lst
  1|2|3|4
  </code></pre>
  
  <p>In context, the delimited string to be used in a <a href="https://www.gnu.org/software/sed/manual/sed.html" rel="noreferrer">sed</a> command for further parsing.</p>