perl -e 'open FILE, "<".shift; @arq=; $a=shift; foreach(@arq[-10..-1]){print if /$a/} while(1){while(){print if /$a/}}' file regex