No clue if I'm doing this right, but what I'm trying to accomplish is add the current date and time to each line of the output.
Code:
#!/bin/bash
today=date +"%D"
hour=date +"%T"
for y in 205 206 207 208
do
COUNT=1
while [ $COUNT -lt 253 ]; do
snmpget -v 2c -Ovq -r 0 -c public 1.1.$y.$COUNT 1.3.6.1.4.1.9986.3.5.2.1.3.0 SNMPv2-SMI::enterprises.9986.3.5.2.6.2.2.5.4.1.2.1.1.1.1 SNMPv2-SMI::enterprises.9986.3.5.2.6.2.2.5.2.1.2.1.1.1 1.3.6.1.4.1.9986.3.5.2.6.2.2.5.1.1.17.1.1 1.3.6.1.4.1.9986.3.5.2.6.2.2.5.1.1.13.1.1 1.3.6.1.4.1.9986.3.5.2.6.2.2.5.1.1.14.1.1 1.3.6.1.4.1.9986.3.5.2.6.2.2.5.1.1.11.1.1 1.3.6.1.4.1.9986.3.5.2.6.2.2.5.1.1.12.1.1 1.3.6.1.4.1.9986.3.5.2.6.2.2.5.1.1.32.1.1 SNMPv2-SMI::enterprises.9986.3.5.2.3.2.0 | sed -n '1h;2,$H;${g;s/\n/;/g;p}' >> data.xls
let COUNT=COUNT+1
done
done
sed -i 's/$/$today;$hour/' data.xls
I thought that
Code:
sed -i 's/$/$today;$hour/' test
would work but it only adds $today;$hour to the file.
Any help would be greatly appreciated
Thanks in advance.
SeeFor