I have a folder with many different files. I want to display a specific line from the last 100 line of a list of files.
So far I have tried both Grep and Tail but neither gave me exactly what I want:
Example: the folder has the following files:
Content of file_n.txt is:
Goal: Only list test_result from last 10 lines of each file_n.txt (line 90 to line 99)
What I have tried so far:
tail -n 10 file_* | grep test_result
The above display almost what I needed but I also need the file name for each result comes from, but for the life of me I can't figure out how to do it.
for f in file_*
do
echo "$f"
tail -n 10 "$f" | grep test_result
done