Hi all,
At the moment, I am doing the following to exclude some exception strings. The more I need to exclude, the longer the string becomes and it has become error prone as I edit the list manually.
$ cat output.txt
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.101 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.105 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.98 user=mickey
host=192.168.1.111 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.102 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.104 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.9 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.103 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.107 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.123 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.108 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.109 user=mickey
host=192.168.1.99 user=mickey
$ egrep "192.168.1.101|192.168.1.102|192.168.1.103|192.168.1.123" output.txt
host=192.168.1.101 user=mickey
host=192.168.1.102 user=mickey
host=192.168.1.103 user=mickey
host=192.168.1.123 user=mickey
$ egrep -v "192.168.1.101|192.168.1.102|192.168.1.103|192.168.1.123" output.txt
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.105 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.98 user=mickey
host=192.168.1.111 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.104 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.9 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.107 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.108 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.99 user=mickey
host=192.168.1.109 user=mickey
host=192.168.1.99 user=mickey
I presume I can do something like assign several variables and then concatenate them together and will be trying this out later, so something like below:
$
set1="192.168.1.101|192.168.1.102"
set2="192.168.1.111|192.168.1.112"
all_set="${set1}|${set2}"
egrep -v "${all_set}" output.txt
I am sure someone can suggest a better and more efficient way of doing this. I am hoping to be able to use an exception file and use that as an exclusion list when parsing output.txt but can't find an example of how to do it like that. So if I need to exclude more search string, then I just edit that exception file. And that exception file can contain other things to exclude too which is a more efficient way of doing a search <file> but exclude <strings>.
Please advise of tips and examples that I can try.