Find all files matching 'name' on linux system, and search with them for 'text'

前端 未结 5 1505
猫巷女王i
猫巷女王i 2020-12-24 12:04

I need to find all instances of \'filename.ext\' on a linux system and see which ones contain the text \'lookingfor\'.

Is there a set of linux command line operation

5条回答
  •  攒了一身酷
    2020-12-24 12:51

    A more simple one would be,

    find / -type f -name filename.ext -print0 | xargs -0 grep  'lookingfor'
    

    -print0 to find & 0 to xargs would mitigate the issue of large number of files in a single directory.

提交回复
热议问题