Editing for simplicity.
Adding existing variables:
time=`date +'%d%m%y_%H%M'`
temp_file=temp\_$input_file.txt
final=$time\_Parsed_CSV.config
Original CSV ($temp_file) - actual names are not 'host/group' anything - need to filter based on $2
host_a,host,192.168.0.1
host_b,host,192.168.0.2
host_c,host,192.168.0.3
group_a,group,host_a
group_a,group,host_b
group_b,group,group_a
group_b,group,host_c
Need an AWK String to parse $2 'group' objects as follows:
When $2 = 'group' AND $3 = an object who is also defined as a group elsewhere (such as group_a), command needs to be:
awk -F "[,|]" '{if ($2=="group") print "set security address-book global address-set",$1,"address-set",$3}' $temp_file >> $final
Else - Assume it is a normal host, and print this:
awk -F "[,|]" '{if ($2=="group") print "set security address-book global address-set",$1,"address",$3}' $temp_file >> $final
I would expect the output to look like: For Nested Groups (group_A within group_b):
set security address-book global address-set group_b address-set group_a
For normal hosts in a group (host_a in group_a)
set security address-book global address-set group_a address host_a