What is the difference between find with grep?

前端 未结 3 463
死守一世寂寞
死守一世寂寞 2021-02-03 10:14

What is the difference between these command:

find . –type f –name \'*txt*\' 

and

find . –type f | grep \'txt\'
3条回答
  •  既然无缘
    2021-02-03 11:07

    In your first example, you are using the find utility to list the filenames of regular files where the filename includes the string txt.

    In your second example, you are using the findutility to list the filenames of regular files and feeding the resultant filenames via a pipe to the grep utility which searches the contents of each file for the string txt. Each time the string is found, the corresponding line of the file is outputted.

提交回复
热议问题