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)
|