Please check the attachment for the example.
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 comments. the environment as follows:
HPUX 11
Bourne Shell, no bash
AWK, no NAWK
---------- Post updated at 01:14 AM ---------- Previous update was at 01:01 AM ----------
It's cool. Thanks! I am not good at PERL
If I want to summarize the strings "abc" in one line(also more than 200 times). The script of PERL should be ?
$ cat inputfile
abc,pqr,nye,qoew,aslkjgb,abc,alskjdf,alsdkjf,abc
abc,pqr,nye,qoew,aslkjgb,abc,alskjdf,alsdkjf,abc,abc
$
$ perl -ne 'print "Line $. has ".s/abc//g." occurrence(s) of abc\n"' inputfile
Line 1 has 3 occurrence(s) of abc
Line 2 has 4 occurrence(s) of abc
---------- Post updated at 12:51 ---------- Previous update was at 12:45 ----------
It's surprising that awk one-liners from post #2, #5 aren't working on your system!