Quote:
|
Originally Posted by ymho
pls advise how to count pattern occurrences in a line.
#:#1#:#2#:#3#:#4
=> no of #:# : 4
|
Actually there're 5 (five) fields in this record: '', '1', '2', '3', '4'
but if don't want to count the first 'empty' field, you can always substract '1':
Code:
echo "#:#1#:#2#:#3#:#4" | awk -F'#:#' '{ print NF-1}'