I have a switch configuration with me in config.txt file .I have opened this file into tcl with set fd [open config.txt r] and and o/p of puts $fd ,
switchport
switchport access vlan 333
switchport mode access
switchport port-security
switchport port-security maximum 5
Now I want to parse this o/p to another file called newconfig.txt and it should look like following,
switchport
switchport access vlan 333
switchport mode access
switchport port-security
switchport port-security maximum 5
Can anybody tell me how to this as this file is very large and I want to make more readable.
Thanks in advance
If I understood correctly, you want the resulting file to contain all lines from the source file separated by blank lines. This can be done by just appending an extra newline character (
\n) to each line from the source file and writing it out to the resulting file, like this: