I am trying to print occurrences of a field in a .csv file only using an awk command. For example in a file test.csv like so:
layla;rebel;TAT
han_solo;rebel;TAT
darth_vader;empire;DKS
yoda;rebel;TAT
with the command:
cat test.csv | ./how_many_are_we.sh dks
I wish to have the following output:
1
Here is my code in how_many_are_we.sh (which is working but case-sensitive):
#! /bin/bash
awk -F ";" -v location=$1 'BEGIN {count=0;} { if ($3 == location) count+=1} END {print count}'
I tried adding IGNORECASE=1 in different places but I can't seem to find the right way to make it work.
Excuse my bad wording, and thank you for the help.