how perform grep operation on all files in a directory

后端 未结 5 1906
情书的邮戳
情书的邮戳 2020-12-02 04:21

Working with xenserver, and I want to perform a command on each file that is in a directory, grepping some stuff out of the output of the command and appending it in a file.

5条回答
  •  时光取名叫无心
    2020-12-02 05:10

    Use find. Seriously, it is the best way because then you can really see what files it's operating on:

    find . -name "*.sql" -exec grep -H "slow" {} \;
    

    Note, the -H is mac-specific, it shows the filename in the results.

提交回复
热议问题