I'm parsing a router configuration file and printing out some of the fields. Given the following output,
I'd like to add the filename to the first column. I'm definately a neophyte in scripting.
COUNTER=${#array1
[*]}
while [ $COUNTER -ne -1 ]; do
######## echo -n $JUNOS_FILE | awk '{ printf "%-20s" , $0 }'
echo ${array0[$COUNTER]} | awk '{ printf "%-20s" , $1 }'
echo ${array3[$COUNTER]} | awk '{ printf "%-50s" , $0 }'
echo ${array2[$COUNTER]} | awk '{ printf "%-20s \n" , $1 }'
let COUNTER=COUNTER-1
done
------------------------- OUTPUT ---------------------------------------------------------------
lo0 LB rtr-management 127.0.0.1/32
t1-1/0/1 TZ Unused
t1-1/0/0 S3/0/16:0 ATT 69DHZA382XXX 10.255.74.62/30
ge-0/0/3 GE Reserved for WAN
ge-0/0/2 GE ZZZ-Test 10.213.0.109/30
ge-0/0/1 GE Unused-ge-0/0/1
ge-0/0/0 GE ECD_28307_00 Juniper J2320 10.213.101.19/27
-----
-----
When I try to add the filename the I get an extra row on top that I don't want. Appears to be
the filename echos twice somehow.
Any ideas??
COUNTER=${#array1
[*]}
while [ $COUNTER -ne -1 ]; do
echo -n $JUNOS_FILE | awk '{ printf "%-20s" , $0 }'
echo ${array0[$COUNTER]} | awk '{ printf "%-20s" , $1 }'
echo ${array3[$COUNTER]} | awk '{ printf "%-50s" , $0 }'
echo ${array2[$COUNTER]} | awk '{ printf "%-20s \n" , $1 }'
let COUNTER=COUNTER-1
done
------------------------- OUTPUT ---------------------------------------------------------------
router-config-1
router-config-1 lo0 LB rtr-management 127.0.0.1/32
router-config-1 t1-1/0/1 TZ Unused
router-config-1 t1-1/0/0 S3/0/16:0 ATT 69DHZA382XXX 10.255.74.62/30
router-config-1 ge-0/0/3 GE Reserved for WAN
router-config-1 ge-0/0/2 GE ZZZ-Test 10.213.0.109/30
router-config-1 ge-0/0/1 GE Unused-ge-0/0/1
router-config-1 ge-0/0/0 GE ECD_xxxxx_00 Juniper J2320 10.213.101.19/27