how to use the unix “find” command to find all the cpp and h files?

后端 未结 6 1949
南笙
南笙 2021-02-01 03:18

I know that to find all the .h files I need to use:

find . -name \"*.h\"

but how to find all the .h AND .cpp

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 03:54

    You can use find in this short form:

    find \( -name '*.cpp' -o -name '*.h' \) -print
    

    -print can be omitted. Using -o just between expressions is especially useful when you want to find multiple types of files and do one same job (let's say calculating md5sum).

提交回复
热议问题