Grep regex NOT containing string

前端 未结 3 454
攒了一身酷
攒了一身酷 2020-12-12 12:33

I am passing a list of regex patterns to grep to check against a syslog file. They are usually matching an IP address and log entry;

grep "1         


        
3条回答
  •  旧时难觅i
    2020-12-12 12:52

    grep matches, grep -v does the inverse. If you need to "match A but not B" you usually use pipes:

    grep "${PATT}" file | grep -v "${NOTPATT}"
    

提交回复
热议问题