Unix Command to List files containing string but *NOT* containing another string

后端 未结 6 1723
春和景丽
春和景丽 2021-01-30 22:01

How do I recursively view a list of files that has one string and specifically doesn\'t have another string? Also, I mean to evaluate the text of the files, not the filenames.

6条回答
  •  囚心锁ツ
    2021-01-30 22:30

    Try this:

    grep -rl  | xargs grep -L 
    

    Explanation: grep -lr makes grep recursively (r) output a list (l) of all files that contain . xargs loops over these files, calling grep -L on each one of them. grep -L will only output the filename when the file does not contain .

提交回复
热议问题