Hello
I have the following output and want the output to look:
FROM:
GigabitEthernet0/0 is up, line protocol is up
1 input errors, 0 CRC, 0 frame, 1 overrun, 0 ignored
275 output errors, 0 collisions, 3 interface resets
GigabitEthernet0/1 is up, line protocol is up
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
42 output errors, 0 collisions, 3 interface resets
TO: (in CSV format)
Interface, Input Errors, Output Errors
GigabitEthernet0/0, 1, 275
GigabitEthernet0/1, 0, 42
When I put the above in a for loop I get staggered outputs as I'm greping on the turn of every loop
Here's my script
for line in $(cat $DATAFILE/$rname.intfs)
do
intf=$(echo $line | grep "line protocol is " | awk '{print $1}')
inerrs=$(echo $line | grep "input error" | sed 's/^[ \t]*//;s/[ \t]*$//' | awk '{print $1}')
outerrs=$(echo $line | grep "output error" | sed 's/^[ \t]*//;s/[ \t]*$//' | awk '{print $1}')
echo "$intf,$inerrs,$outerrs" >intf.csv
done
Any help is appreciated
thanks
Jay