Hey, thank you for that... I did not see it was duplicated... it did not keep the script from running, it just addded unecessary steps to it..
Well, I am new to sed, but from what I read -e is to inform that the following is still part of the script (instead of going sed "1..."; sed "2..."; sed "3..." you use sed -e "1..." -e "2..." -e "2..."). As for g, it is to replace all occurrences of searched text, isn't it? Well they may appear more than once on the template files...
Here is one record from the source file (all sensitive data was replaced, line break for readability):
persio@dynaserver:~/CUS$ more test
,"United States",226,,10.10.10.@,,10.10.10.@,255.255.255.128,Springfield,coresw1.cutomer.com,
WS-C3750G-12S-E,SERIALNO,SWIA8,12.2(35)SE5,10.10.10.@,255.255.255.192,Vlan997,"Switch Co
re L3",1,10.10.10.10,,,,2,ospf 12345,area 0,hsrp,,,,SWL3-2,#N/A,226-10_10_10_@-SWL3-2.txt
persio@dynaserver:~/CUS$
This record will use the following template according to its UnID (in red):
persio@dynaserver:~/CUS$ more SWL3-2
config t
!
vlan 996
desc Management VLAN
!
interface vlan 996
ip address IP_MGMT NEW_MASK
!
router ROUTING_PROCESS
network IP_MGMT 0.0.0.0 OSPF_AREA
!
! Trunk Configuration
TRUNK_DATA
! End trunk configuration
end
persio@dynaserver:~/CUS$
And when I run the script, this is the output file:
persio@dynaserver:~/CUS$ ./generate_config.sh test
reading test
persio@dynaserver:~/CUS$ more CONFIGS/SWL3-2/226-10_10_10_@-SWL3-2.txt
config t
!
vlan 996
desc Management VLAN
!
interface vlan 996
ip address 10.10.10.@ 255.255.255.128
!
router "ospf 10226"ESS
network 10.10.10.@ 0.0.0.0 "area 0"
!
! Trunk Configuration
interface FastEthernet0/0
switchport trunk allowed vlan add 996
! End trunk configuration
end
persio@dynaserver:~/CUS$
Details in blue are placeholder (on template) and replaced data (on output). Deatils in orange are unwanted characters that sed is including to the output file. I wanted to understand (1) why is it happening and (2) what can I do to prevent that?