[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] how to grep the last match out from a bunch of files
From: |
lina |
Subject: |
[Help-bash] how to grep the last match out from a bunch of files |
Date: |
Wed, 28 Dec 2011 01:03:33 +0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 |
Hi,
I have a bunch of files like a_*.txt
it contains many "step" in a_*.txt
$ cat a_1.txt
step
1
step
2
step
3
some lines appended here
$ cat a_2.txt
step
1
step
2
step
3
step
4
some other lines appended at the end
I wish to get the final step,
for a_1.txt it's 3
for a_2.txt it's 4
so output it's something like
a_1.txt 3
a_2.txt 4
I tried,
$ grep -A 1 -l step a_*.txt
a_1.txt
a_2.txt
not work,
Thanks for any suggestions,
Best regards,
- [Help-bash] how to grep the last match out from a bunch of files,
lina <=