We have arrived to a flag that I pretty much use all the time.
The -n
shows you the line number of the found search pattern.
Ok, back to our test.txt
file with the following content:
sad
happy
awake
coffee
work
school
Using the -n
flag we can find exactly which line “coffee” is on:
$ grep -n "coffee" test.txt
4:coffee