Search String: Find and Grep

前端 未结 4 2074
忘掉有多难
忘掉有多难 2021-02-04 17:13

There must be a better / shorter way to do this:

# Find files that contain  in current directory
#   (including sub directories) 
$ find .          


        
4条回答
  •  忘了有多久
    2021-02-04 17:57

    Not sure what do you mean by better, my first thought was something like this:

    grep  $(find -regex .*\.html)
    

    But that's worse because result of the find would be accumulated somewhere in shells memory and then sent as a huge chunk of input arguments

    The only imporvement I see too your suggestion is

    find -regex .*\.html | xargs grep 
    

    That way find performs all the filtering and you still retain piped processing

提交回复
热议问题