仅在找到所需文件后的最后一行 Grep [英] Grep only last line after find needed files
本文介绍了仅在找到所需文件后的最后一行 Grep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我有一个来自 这个帖子
Hi guys I have an extended question from this thread
我需要找到一些给定文件名的文件,并在这些文件的最后一行使用 grep 来查找某个字符串.
I need to find some files given file name and use grep on the last lines of these files to find a certain string.
我目前有:
find my_dir/-name "*filename*" |xargs grep '寻找'
我是使用这些命令的新手,我将不胜感激.提前谢谢你.
I'm new to using these commands so much help would be appreciated. Thank you in advance.
推荐答案
例如你可以这样做:
find my_dir/ -name "*filename*" -exec sh -c "tail -200 {} | grep lookingfor" ;
将 200
设置为您想要的最后一行数.
setting 200
to the number of last lines you want.
这篇关于仅在找到所需文件后的最后一行 Grep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文