I have a file like this
1|2345|John|Smith
2|4563||Smith
3|5968||Doe
4|896|Rick|Lawson
5|889||Eddy
How do I count the number of rows that have data in the third column?
awklinuxtext processing
I have a file like this
1|2345|John|Smith
2|4563||Smith
3|5968||Doe
4|896|Rick|Lawson
5|889||Eddy
How do I count the number of rows that have data in the third column?
Best Answer
On the sample input, it results in:
It works by setting the field separator to pipe, then increments
count
on lines that have a non-empty value in the 3rd field. At the end of the file, it prints the finalcount
.