How to find files that have certain string in last line
Let’s say you have few files
string |-- 1 |-- 2 |-- 3 |-- 4 |-- 5 |-- 6 |-- 7 |-- 8 `-- 9
And they may end with two different endings: aaa or bbb.
Finding list off files that have given string at the end can be done following way
> find string -name "*" -exec tail -v -n1 {} \; | grep "bbb" -B1
on macOS you have to go slightly different way
> find string -name "*" | xargs tail -1 | grep "bbb" -B1
June 12th, 2019 in
main entries