PDA

View Full Version : Grep Last Pattern Output



cfriend
09-18-2004, 08:54 AM
Hi

Is there any way with grep to show me only the last pattern that matches and not all ? For example for a file with

linux 56
slackware 32
debian 34
linux 2
redhat 9

and $> grep linux filename

show me only --> linux 2
and not

linux 56
linux 2

Thanks

Perspective
09-18-2004, 10:14 AM
grep foo filename | tail -1


off topic: woohoo, post 10 hundred! :)