Using the unique tariff list I wanted to count the number of customers with each tariff/tariff-addon combination on the system. So I cam up with the following grep:
cat uniq-tariff-addon.csv | while read tariff
do
echo $tariff `grep -c $tariff customer_tariff_list.csv` >> sub-tariffcount.csv; done
My problem being that it catches the customers with a tariff-addon in the count of just tariff only as follows:
customernumber,tariff
012345678910,T0001
012345678911,T0002
012345678912,T0001-A0001 (where A000X is an addon)
grep -c T0001 in the above file would return a count of 2
grep -c T0001-A0001 in the above file would return a count of 1
How can I get it to count T0001 and not catch T0001-A0001 as well?
The above is the only entry for anyone with this old tariff on the system, but as you can see they have an addon, which means it shouldn't be caught by grep.