Getting the last match in a file using grep

You could try

grep pattern file | tail -1

or

tac file | grep pattern | head -1

or

tac file | grep -m1 pattern

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)