I'm trying to find out if an address definition is used inside of fortigate configuration file.
I extracted the section out of the configuration file, that contains the addresses. In that section the lines look like this:
edit "address name"
set associated-interface "someinterface"
set subnet 1.1.1.1 0.0.0.0
So now I wanted to use the address name and check if any rule or address group uses this by doing the following:
IFS='
'
for address in $(grep edit addresses.txt | cut -c10- | sed 's/"//'g); do echo $address; grep -n $address fortigate.conf; done
The IFS part I took from here.
This returns me a list of names of address definitions, but the grep command doesn't find anything, which is weird, since it should at least find itself, no?