Grep only the first match and stop

后端 未结 5 1963
误落风尘
误落风尘 2020-11-29 15:14

I\'m searching a directory recursively using grep with the following arguments hoping to only return the first match. Unfortunately, it returns more than one -- in-fact two

5条回答
  •  天命终不由人
    2020-11-29 15:29

    You can use below command if you want to print entire line and file name if the occurrence of particular word in current directory you are searching.

    grep -m 1 -r "Not caching" * | head -1
    

提交回复
热议问题