I have something that almost works the way you want it. What this expansion does is:
- Slurp in the file, using ; as the separator.
- Exclude any lines with # in them (i.e. comments).
- It should skip blank lines, but my regex isn't matching, it still includes those blank lines, so I just removed it and left the or{{}{}} block in there.
- Extract the item before the : on each line, and extract the domain from that.
- Mash it all up into the list.
I don't profess this to be exactly what you need, but it shows how the lists can be parsed and grep'd.
CentOS58[root@ivwm41 exim]# more test_list.cf
[email protected]: [email protected]
# ignore this line
[email protected]: [email protected]
[email protected]: [email protected]
CentOS58[root@ivwm41 exim]# exim -be '${reduce {<; ${readfile{/etc/exim/test_list.cf}{;}} } {} {${if or{ {match{$item}{#}} {match{$item}{#}} } {$value} {$value:${sg {${extract{1}{:}{$item}}} {^.*@}{} }}}}}'
:test.com:test.com:hugo.com
If you spread out the expansion logically into its individual parts, it looks like this:
exim -be '${reduce {<; ${readfile{/etc/exim/test_list.cf}{;}} }
{}
{${if or{ {match{$item}{#}} {match{$item}{#}} }
{$value}
{$value:${sg{${extract{1}{:}{$item}}} {^.*@} {}}}}
}
}
'
One thing that still needs to be fixed is that leading : should not be there. I'm not 100% sure why it is there :-/ and I don't really have the time to delve any further into it. The logic needs to be massaged a bit to catch whatever condition is causing that leading colon to appear and then the result should be a domain list that you can use as a condition.