Count lines AWK

Hi, how can I count the lines where a word appears in a file, using AWK?

Example:

file.txt:

gold 1588 France
gold 1478 Spain
silver 1596 France
emerald 1584 UK
diamond 1478 Germany
gold 1639 USA

Number of lines where gold in text is = 3

I've try this, but all I get is the number of the current line where the word is located.

count.awk:

awk '
/gold/ { print NR }' file.txt

Result:

1
2
6
awk '/gold/{i++}END{print i}' file.txt
1 Like

Thanks!

How about:

grep -c 'gold' file.txt
2 Likes