Find Command that returns line number of the string

前端 未结 2 1645
春和景丽
春和景丽 2021-01-04 18:40

I have a bunch of files organized into directories..All these are text files (c/c++). I am trying to understand this code and i need to look at the declarations of many vari

2条回答
  •  鱼传尺愫
    2021-01-04 19:33

    find . -name *.c -exec grep -Hn "your search term here" {} \;
    

    If you really want to use find.

    EDIT

    explanation

    find . -name *.c - find files in current dir and below where name is like *.c

    -exec - execute command that follows

    grep -Hn - grep and print results with file name and line number of match

    {} \; - {} marks where the name of each file found will be substituted and the backslash- semicolon marks the end of the command to execute.

提交回复
热议问题