title: Assign fields to variables - Bash
body: <p>Suppose I have a string with pipe separator:</p>
  
  <pre><code>str="1|2|3|4"
  </code></pre>
  
  <p>I want them to be assigned to specific variables.</p>
  
  <pre><code>var_a=1
  var_b=2
  var_c=3
  var_d=4
  </code></pre>
  
  <p>I am doing it in this way:</p>
  
  <pre><code>var_a="`echo $str | cut -d'|' -f1`"
  var_b="`echo $str | cut -d'|' -f2`"
  var_c="`echo $str | cut -d'|' -f3`"
  var_d="`echo $str | cut -d'|' -f4`"
  </code></pre>
  
  <p>Can this be done in an efficient way? Please suggest.</p>