title: shell script to sum column with if else
body: <p>I would like to sum the second column of a CSV file. </p>
  
  <p>I used the code below:</p>
  
  <pre><code>awk -F'#' '{c+=$2}END{printf "count=%d\n",c}' file.csv
  </code></pre>
  
  <p>It works perfectly. 
  Now I would like to add <code>ifelse</code> condition to it. 
  I would like to sum column 2 only if colum 3 = 'A' and Column 4 = 'B' </p>
  
  <p>I add an <code>ifelse</code> clause but it doesn't work </p>
  
  <pre><code>awk -F'#' 'if [ "$3" == 'A' &amp;&amp; "$4" == 'B' ]; then c+=$2; fi
  END{printf "count=%d\n",c}' file.csv
  </code></pre>