How do I create a script that provides a count of distinct values of a particular field in a file utilizing commonly available UNIX commands (sh or awk)?
Field1|Field2|Field3|Field4
AAA|BBB|CCC|DDD
111|222|333|777
AAA|EEE|ZZZ|EEE
111|555|333|444
AAA|EEE|CCC|DDD
111|222|555|444
For the above file, the result I am looking for would be:
Field1
AAA(3)
111(3)
Field2
BBB(1)
222(2)
EEE(2)
555(1)
Field3
ccc(2)
333(2)
zzz(1)
555(1)
Field4
DDD(2)
777(1)
EEE(1)
444(2)
Thank you in advance for your assistance.