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

前端 未结 14 1790
一个人的身影
一个人的身影 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 04:01

    1. grep -r "yourstring" * Will find "yourstring" in any files and folders

    Now if you want to look for two different strings at the same time you can always use option E and add words for the search. example after the break

    1. grep -rE "yourstring|yourotherstring|$" * will search for list locations where yourstring or yourotherstring matches

提交回复
热议问题