Here is an example
Interface {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} IP-Address {} {} {} {} {} OK? Method Status {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {Protocol
FastEthernet0/0} {} {} {} {} {} {} {} {} {} {} {} unassigned {} {} {} {} {} YES unset {} administratively down down {} {} {} {
FastEthernet0/1} {} {} {} {} {} {} {} {} {} {} {} unassigned {} {} {} {} {} YES unset {} administratively down down
I want remove {} in this.
I assumed all the above string interface variable
set interface [string trimright [string trimleft $interface "{}"] "{}"]
but it doesn’t work. How to remove the {} in my example?
I suspect you’re doing this: starting with a string and trying to split it into words, only Tcl’s
splitcommand is producing a list with lots of empty values:Tcl’s
splitsplits on individual whitespace characters by default (unlike awk or perl that splits on consecutive whitespace chars).You can some choices to make your life easier:
1) use regexp to find all “words”
2) use the textutil package for a split command that acts like you seem to expect: