You may use this awk
:
awk -F "|" '{++fq[NF-1]} END {for (f in fq) printf "%d line(s) have %d occurrence(s) of %s
", fq[f], f, FS}' file
1 line(s) have 1 occurrence(s) of |
1 line(s) have 2 occurrence(s) of |
4 line(s) have 3 occurrence(s) of |
To make it more readable:
awk -F "|" '{
++fq[NF-1]
}
END {
for (f in fq)
printf "%d line(s) have %d occurrence(s) of %s
", fq[f], f, FS
}' file
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…