perl -Mstrict -ne "m/addr/ and eval {print @@; exit}; shift(@@) if push(@@,$_)>5" myfile.txt