I have the following lines:
123;123;#rss
123;123;#site #design #rss
123;123;#rss
123;123;#rss
123;123;#site #design
and need to count how many times each tag appears, do the following:
grep -Eo '#[a-z].*' ./1.txt | tr "\ " "\n" | uniq -c
i.e. first select only the tags from the strings, and then break them down and count it.
output:
1 #rss
1 #site
1 #design
3 #rss
1 #site
1 #design
instead of the expected:
2 #site
4 #rss
2 #design
It seems that the problem is in the non-printable characters, which makes counting incorrect. Or is it something else? Can anyone suggest a correct solution?