grep, but only certain file extensions

前端 未结 12 2526
野性不改
野性不改 2020-12-02 03:18

I am working on writing some scripts to grep certain directories, but these directories contain all sorts of file types.

I want to grep jus

12条回答
  •  没有蜡笔的小新
    2020-12-02 03:49

    The below answer is good:

    grep -r -i --include \*.h --include \*.cpp CP_Image ~/path[12345] | mailx -s GREP email@domain.com
    

    But can be updated to:

    grep -r -i --include \*.{h,cpp} CP_Image ~/path[12345] | mailx -s GREP email@domain.com
    

    Which can be more simple.

提交回复
热议问题