in reply to Re^2: how to find last word match ?
in thread how to find last word match ?

As a Perl one-liner, from the Unix command line, that would be:

perl -ne '/Baki/ and $x=$_}{print$x' file.txt
or:
perl -ne '/Baki/ and $x=$_; END{print$x}' file.txt

Update: BTW, your shell solution:
cat file.txt |grep "Baki" |tail -1
should read:
grep 'Baki' file.txt |tail -1
Tom Christiansen once wrote long ago on usenet something like "If you find yourself calling cat with just one argument, you're probably doing something silly".

Update: See also Re: perl one liner for csv file one field (useless use of cat and other awards References)

Replies are listed 'Best First'.
Re^4: how to find last word match ?
by happy.barney (Friar) on Nov 24, 2010 at 08:08 UTC
    perl -e 'print((grep/Baki/,<>)[-1])' file.txt