简体   繁体   中英

How can I find all files with a certain line in the source?

I am using linux trying to find all files that contain the phrase "Hello" in them (not the filename) and then delete them all. How can I do this?

grep --recursive --files-with-matches Hello $HOME | xargs -d '\n' rm -f

当然,您需要确保grep仅找到要删除的文件,因为此管道完全无法原谅错误

It took me 5 seconds to find google it:

find . -exec grep -n hello /dev/null {} \\;

Of course, I could be lying and that could format your hard disk :^)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM