嗨,我想创建一个脚本,将附加到现有文件:这是文件的外观:
{| border="1" cellspacing="5" cellpadding="2" style="text-align: center;"
|-
! DataStore-1:
! 11/14/12
! 11/16/12
! 11/30/12
|-
| Total ios
| [[File:datastore-1-Tios-11-14-2012.png| 100px]]
| [[File:datastore-1-Tios-11-16-2012.png| 100px]]
| [[File:datastore-1-Tios-11-30-2012.png| 100px]]
|-
| Read %
| [[File:datastore-1-readp-11-14-2012.png| 100px]]
| [[File:datastore-1-readp-11-16-2012.png| 100px]]
| [[File:datastore-1-readp-11-30-2012.png| 100px]]
|-
| Cache Hit %
| [[File:datastore-1-cachep-11-14-2012.png| 100px]]
| [[File:datastore-1-cachep-11-16-2012.png| 100px]]
| [[File:datastore-1-cachep-11-30-2012.png| 100px]]
|-
| Current kB/sec
| [[File:datastore-1-ckbsec-11-14-2012.png| 100px]]
| [[File:datastore-1-ckbsec-11-16-2012.png| 100px]]
| [[File:datastore-1-ckbsec-11-30-2012.png| 100px]]
|-
| Maximum kB/sec
| [[File:datastore-1-mkbsec-11-14-2012.png| 100px]]
| [[File:datastore-1-mkbsec-11-16-2012.png| 100px]]
| [[File:datastore-1-mkbsec-11-30-2012.png| 100px]]
|-
| Current IO/sec
| [[File:datastore-1-ciosec-11-14-2012.png| 100px]]
| [[File:datastore-1-ciosec-11-16-2012.png| 100px]]
| [[File:datastore-1-ciosec-11-30-2012.png| 100px]]
|-
| Max IO/sec
| [[File:datastore-1-miosec-11-14-2012.png| 100px]]
| [[File:datastore-1-miosec-11-16-2012.png| 100px]]
| [[File:datastore-1-miosec-11-30-2012.png| 100px]]
|-
|}
基本上我希望能够在 DataStore-1 字段下为“日期”添加一个条目,例如:
|-
! DataStore-1:
! 11/14/12
! 11/16/12
! 11/30/12
! 12/03/12
|-
一旦我这样做了,我还想为使用相同可变日期的每个其他字段添加一个附加条目,例如:
| -
| Total ios
| [[File:datastore-1-Tios-11-14-2012.png| 100px]]
| [[File:datastore-1-Tios-11-16-2012.png| 100px]]
| [[File:datastore-1-Tios-11-30-2012.png| 100px]]
| [[File:datastore-1-Tios-12-03-2012.png| 100px]]
|-
[...]
我正在考虑为文件的每个部分创建一个函数,但我的逻辑已经足够了......
writedates ()
{
SOURCEFILE=/mnt/bacchuscore-logger/netmon/wikipages/sourcefile.wk
DATASTORENUM=`head -1 $SOURCEFILE|cut -d '=' -f2`
DATESECTION=dates.sec
DATEOUTPUT=newdates.sec
i=0
while read; do
VAR[$i]=$REPLY
DSN=$(echo ${VAR[0]}|cut -d '=' -f2)
DSF=$(echo ${VAR[1]}|cut -d '=' -f2)
DE=$(echo ${VAR[2]}|cut -d '=' -f2)
echo "! $DSF-$DSN"
echo "! $DE"
echo "|-"
((i++))
done < $SOURCEFILE
}
谢谢