I have data that need to be count how many occurrences.
1
2
1
2
3
1
And used the awk command below and work properly.
awk -F'","' '{ a[$1]++ } END { for (n in a) print n "=" a[n] } ' text.txt
And the output:
2=2
3=1
1=3
The other problem is it needs to count how many stored in array. The expectation is I need also to count or number of lines from the output above. Expected Output: 3
awk? Much easier using right tools for this, e.g.... | sort | uniq -c