Count field frequency in a '|' delimited file

I have a large file with fields delimited by '|', and I want to run some analysis on it. What I want to do is count how many times each field is populated, or list the frequency of population for each field.

I am in a Sun OS environment.

Thanks,

  • CB
awk -F "|" '{print "Line no: "NR " has " NF " fields"}' file

Regards

I am getting an error with your awk command:

[PPLDEV_232] /usr/local/data/phase2/dev/extracts/CMS> awk -F "|" '{print "Line no: "NR " has " NF " fields"}' tmp.out > tmp.analyze
awk: syntax error near line 1
awk: bailing out near line 1

  • CB

Use nawk or /usr/xpg4/bin/awk on Solaris.

Regards