Get last lines of file after last line with word TEST

i need to get least lines of file after last word TEST in file, and send that lines to mail

example of file structure:

TEST 10.10.2010
jdfjdnjfndjfndnfkdk
djfjdnfjkdjkfnjkdfk
jdfjdjfnjdjnfjkdnfjk

TEST 11.10.2010
jdjfnjdnfdkdfjdfjdnk
jdnfjdnjkfndnfjdnfjk
fjdnfjkndnfdfnjdnfjk

TEST 12.10.2010
sddhbfhjdbfhdbjbfj
dhbfhdfbdbfhjdbfjb
jndjkfndnfjkdnfkfnk
...
...
$ ruby -00 -ne 's=$_;END{print s}' file

like this:

 
awk '/TEST/ { s=" "; s=$0;next } {s=s"\n" $0} END { print s}' input_file

i forget, i need to send this lines on mail

save the output into a temp file.

man "mail" give you more information on how to send a mail.

remove the temp file

awk '/TEST/{s=_;next}NF{s=((s)?s RS:_)$0}END{print s}' file

Don't forget RS in awk.

awk 'BEGIN{RS=""} /TEST/ {t=$0}END{print t}' infile

---------- Post updated at 11:32 AM ---------- Previous update was at 11:31 AM ----------

no need to save it in temp file.

awk 'BEGIN{RS=""} /TEST/ {t=$0}END{print t}' infile |mailx -s "mail subject" YOUR_MAILBOX@unix.com