grep until last match or last line code example Example: grep until last match grep -n [match] #shows line numbers of matched lines