I am trying to find out how to stream a file so that if gives me back how many times a certain field label occurred.

File example:
Cat black 100 home lost
Dog brown 632 street lost
Dog black 839 home owned
Pig pink 123 mud farm
Dog white 345 street lost

I would like to find out how many times does "Dog" appear in the file using the AWK command if possible or maybe even another command that is capable.

I am trying to find out how to stream a file so that if gives me back how many times a certain field label occurred.

File example:
Cat black 100 home lost
Dog brown 632 street lost
Dog black 839 home owned
Pig pink 123 mud farm
Dog white 345 street lost

I would like to find out how many times does "Dog" appear in the file using the AWK command if possible or maybe even another command that is capable.

awk 'BEGIN { num = 0 } ; END { print num } ; /dog/ { num = num + 1 }' < input.file

Change regex to fit your need...
Or put in .awk file and run as program, im not to much into how those files takes arguments but it should be doable...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.