Using my limited scripting knowledge.. I have put together an expect script to run some commands on specific devices. The output is below and is saved from all devices to a file (I just listed 2 devices as an example).
Current State : Active
Router1slot1# showstats
Active stats : 31
Active stats1 : 47
Router1slot1# exit
Current State : Standby
Router1slot2# showstats
Active stats : 59
Active stats1 : 56
Router1slot2# exit
What I would like is to get some values from the output and have them displayed in rows, delimited by "," :
Router1slot1,Active,31,47
Router1slot2,Standby,59,56
I got a step closer to what I want using :
cat switch.log | awk '/# show/ {print substr($1,1)} /State :/ {print substr($4,1)} /: / {print substr($5,1)}' >> awk.csv
Output:
Active
Router1slot1#
31
47
Standby
Router1slot2#
59
56
From here I tried different options to convert rows to columns, but it doesn't seem to work. The output is similar to:
56uter1slot2#59
Is there any (more efficient) way to get the required format?