Count character in one line

view full story

http://www.unix.com – Please check the attachment for the example. Attachment 2491 Purpose: count how many "|" character in one line and also display the line number. expect result: Line 1 : there are 473 "|" characters Line 2 : there are 473 "|" characters I have tried to use awk to count it, it's ok when the statistic character is less than 199. awk -F'|' '{print NR,FS,NF-1}' 1111.txt awk: Line ||||00000000000033||4 cannot have more than 199 fields. The input line number is 1. The file is 1111.txt. The source line number is 1. Thanks for your advice. (HowTos)