>type file 123 abc def >perl -ne"print if s/.*?(?=abc)//.0" file abc >perl -ne"print if s/.*?(?=abc)//..0" file abc def