Using awk, I would like to print the last matching line of a file. I would like only the matching line itself, not any range of lines. I can use a command like
awk
You can assign values to variables and print them at the end of processing both the lines and their number.
File:
$ cat file foo1 foo2 foo3 4 5
Command:
$ awk '/foo/ {a=$0;n=NR} END{print n, a}' file 3 foo3