thelonelycoder
Part of the Furniture
I'm at a loss, google ends at one point with examples.
Situation:
The Diversion blocking list maps up to 25 domains to an IP, like this example with 3 domains:
Note that there is a space before and after each domain, except the last, which makes it even more tricky.
The regular whitelisting during download of the hosts files works as at that time the file is in one-domain-per-line format. For later whitelisting I need a way of removing explicit domains from the file. Only exact matches may be removed and the integrity of the file must remain intact.
This would be an example whitelist which can be 20 or more lines long:
I want to make this fast, so a "while read line" way is out of the question.
grep -v (select non-matching lines) does not work either, it deletes the whole line which I do with the one-domain-per-line file.
I have an excellent sed command, but that would remove the matching part of icloud.com-locations.in with icloud.com.
I tried adding a space before the domain, like " icloud.com" or the typical word boundary tricks but nothing works to my full satisfaction.
The sed command creates another sed command in itself, like this, taking the whitelist as input and acts on file:
Any help would be appreciated.
Situation:
The Diversion blocking list maps up to 25 domains to an IP, like this example with 3 domains:
Code:
172.18.0.2 hit.123c.vn iclickyou.com icloud.com-locations.in
The regular whitelisting during download of the hosts files works as at that time the file is in one-domain-per-line format. For later whitelisting I need a way of removing explicit domains from the file. Only exact matches may be removed and the integrity of the file must remain intact.
This would be an example whitelist which can be 20 or more lines long:
Code:
icloud.com-locations.in
icloud.com
grep -v (select non-matching lines) does not work either, it deletes the whole line which I do with the one-domain-per-line file.
I have an excellent sed command, but that would remove the matching part of icloud.com-locations.in with icloud.com.
I tried adding a space before the domain, like " icloud.com" or the typical word boundary tricks but nothing works to my full satisfaction.
The sed command creates another sed command in itself, like this, taking the whitelist as input and acts on file:
Code:
sed -i "$(sed 's:.*:s/&//g:' whitelist)" file