3 ms·
I usually prefer to pipe fgrep -v into fgrep -v. With egrep you need to escape brackets and other characters.
by yakubin 4y ago
I usually prefer to pipe fgrep -v into fgrep -v. With egrep you need to escape brackets and other characters.
- chasil 4y agoTrue, for absolute fixed strings, the author's approach is superior. Off the cuff, another way to do it is with awk's index function. I don't know what speed penalty this might impose. $ cat ~/fmgrep #!/bin/awk -f BEGIN { split(ARGV[1], s, ","); ARGV[1]="" } { m = 1; for(c in s) if(index($0, s[c])) m = 0; if(m) print } $ ~/fmgrep sshd,systemd,polkitd /var/log/secure
- mdaniel 4y agoIf you haven't seen it, there's been some noise recently about fgrep and its egrep friend $ fgrep -h fgrep: warning: fgrep is obsolescent; using grep -F $ egrep -h egrep: warning: egrep is obsolescent; using grep -E
- anotherevan 4y agoThis also works: fgrep -v -e THING1 -e THING2 -e THING3 -e THING4