Grep在找到所需文件后仅最后一行 [英] Grep only last line after find needed files
本文介绍了Grep在找到所需文件后仅最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我对我需要找到一些具有给定文件名的文件,并在这些文件的最后几行上使用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.
我目前有:
找到my_dir/-name"*文件名*" |xargs grep'looking'
我对使用这些命令是陌生的,因此将不胜感激.预先谢谢你.
I'm new to using these commands so much help would be appreciated. Thank you in advance.
推荐答案
例如,您可以执行以下操作:
You can for example do:
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屋!
查看全文