How can I use grep to find a word inside a folder?

前端 未结 14 1787
一个人的身影
一个人的身影 2020-12-02 03:07

In Windows, I would have done a search for finding a word inside a folder. Similarly, I want to know if a specific word occurs inside a directory containing many sub-directo

14条回答
  •  青春惊慌失措
    2020-12-02 03:50

    Another option that I like to use:

    find folder_name -type f -exec grep your_text  {} \;
    

    -type f returns you only files and not folders

    -exec and {} runs the grep on the files that were found in the search (the exact syntax is "-exec command {}").

提交回复
热议问题