title: Bash count occurences based on parameters
body: <p>I'm new to bash shell and I have to do a script with a csv file.</p>
  <p>The file is a list of the participants, countries, sports and medals achieved.</p>
  <p>when executing the script, I should give as parameters the <code>nationality</code> (column 3) and the <code>sport</code> (column 8). The script should return the amount of participants of that country for that sport, and the amount of medals achieved.</p>
  <p>The amount of medals achieved is the sum of the columns &quot;gold&quot; &quot;silver&quot; &quot;bronze&quot; of each row which are columns 9,10 and 11.</p>
  <p>I cannot use grep, awk, sed or csvkit.</p>
  <p>So far, I have this code but I'm stuck with the medal counting part.</p>
  <pre><code>nacionality=$1
  sport=$2
  columns= cut -d, -f 3,8 athletes.csv
  echo columns | tr -cd $nacionality,$sport | wc -c
  </code></pre>
  <p>Could anyone help me?</p>
  <p>The file is: <a href="https://github.com/flother/rio2016/blob/master/athletes.csv" rel="nofollow noreferrer">https://github.com/flother/rio2016/blob/master/athletes.csv</a></p>
  <p>The name of the file is <code>script2_4.sh</code></p>
  <p>An example of the output is:</p>
  <pre><code>./script2_4.sh POL rowing
  
   Participants, Medals
  
  
   26, 6
  </code></pre>
  <p>A sample of the file:</p>
  <pre><code>id,name,nationality,sex,date_of_birth,height,weight,sport,gold,silver,bronze,info
  736041664,A Jesus Garcia,ESP,male,1969-10-17,1.72,64,athletics,0,0,0,
  532037425,A Lam Shin,KOR,female,1986-09-23,1.68,56,fencing,0,0,0,
  435962603,Aaron Brown,CAN,male,1992-05-27,1.98,79,athletics,0,0,1,
  521041435,Aaron Cook,MDA,male,1991-01-02,1.83,80,taekwondo,0,0,0,
  33922579,Aaron Gate,NZL,male,1990-11-26,1.81,71,cycling,0,0,0,
  173071782,Aaron Royle,AUS,male,1990-01-26,1.80,67,triathlon,0,0,0,
  266237702,Aaron Russell,USA,male,1993-06-04,2.05,98,volleyball,0,0,1,
  382571888,Aaron Younger,AUS,male,1991-09-25,1.93,100,aquatics,0,0,0,
  87689776,Aauri Lorena Bokesa,ESP,female,1988-12-14,1.80,62,athletics,0,0,0,
  997877719,Ababel Yeshaneh,ETH,female,1991-07-22,1.65,54,athletics,0,0,0,
  343694681,Abadi Hadis,ETH,male,1997-11-06,1.70,63,athletics,0,0,0,
  591319906,Abbas Abubakar Abbas,BRN,male,1996-05-17,1.75,66,athletics,0,0,0,
  258556239,Abbas Qali,IOA,male,1992-10-11,,,aquatics,0,0,0,
  376068084,Abbey D'Agostino,USA,female,1992-05-25,1.61,49,athletics,0,0,0,
  162792594,Abbey Weitzeil,USA,female,1996-12-03,1.78,68,aquatics,1,1,0,
  521036704,Abbie Brown,GBR,female,1996-04-10,1.76,71,rugby sevens,0,0,0,
  149397772,Abbos Rakhmonov,UZB,male,1998-07-07,1.61,57,wrestling,0,0,0,
  256673338,Abbubaker Mobara,RSA,male,1994-02-18,1.75,64,football,0,0,0,
  337369662,Abby Erceg,NZL,female,1989-11-20,1.75,68,football,0,0,0,
  334169879,Abd Elhalim Mohamed Abou,EGY,male,1989-06-03,2.10,88,volleyball,0,0,0,
  215053268,Abdalaati Iguider,MAR,male,1987-03-25,1.73,57,athletics,0,0,0,
  763711985,Abdalelah Haroun,QAT,male,1997-01-01,1.85,80,athletics,0,0,0,
  </code></pre>