我设置Var:
ImgPath = $(找到$ PWD -depth -maxdepth 3 -name" Cpu_U .gif" -o -name" Cpu_S .gif" -o -name" * Memory_Free.gif" | sort -n)
每次读取三行从var到html表。
我写剧本:
#!/bin/sh
ImgPath=$(find $PWD -depth -maxdepth 3 -name "*Cpu_U*.gif" -o -name "*Cpu_S*.gif" -o -name "*Memory_Free.gif" | sort -n)
cat <<EOF1>report.html
<html>
<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333">
<tr><td width="15%" bgcolor="#00FFFF"><span class="STYLE5">TestCase</span></td>
<td width="15%" bgcolor="#00FFFF"><span class="STYLE5">Grinder Component</span></td>
<td width="15%" bgcolor="#00FFFF"><span class="STYLE5">Grinder Component</span></td>
<td width="10%" bgcolor="#00FFFF"><span class="STYLE5">value</span></td>
<td width="15%" bgcolor="#00FFFF"><span class="STYLE5">JVM Arguments </span></td>
<td width="25%" bgcolor="#00FFFF"><span class="STYLE5">value</span></td>
<td width="10%" bgcolor="#00FFFF"><span class="STYLE5">OS Kernal </span></td>
<td bgcolor="#00FFFF"><span class="STYLE5">Value</span></td></tr>
<tr><td rowspan="5"><span class="STYLE9"></span></td>
<td><span class="STYLE10">runMode</span></td>
<td><span class="STYLE10">continuous</span></td>
<td rowspan="5"><span class="STYLE10">Jvm.argument</span></td>
<td rowspan="2"><span class="STYLE10">Hotspot:</span></td>
<td><span class="STYLE10">runMode</span></td>
<td><span class="STYLE10">1</span></td></tr>
<tr><td><span class="STYLE10">durationHour</span></td>
<td><span class="STYLE10">1</span></td>"
<td><span class="STYLE10">durationHour</span></td>
<td><span class="STYLE10">1</span></td></tr>
<tr><td><span class="STYLE10">processors</span></td>
<td><span class="STYLE10">1</span></td>
<td rowspan="3"><span class="STYLE10">JRockit:</span></td>
<td><span class="STYLE10">processors</span></td>
<td><span class="STYLE10">10</span></td></tr>
<tr><td><span class="STYLE10">threads</span></td>
<td><span class="STYLE10">10</span></td>
<td><span class="STYLE10">threads</span></td>
<td><span class="STYLE10">1000</span></td></tr>
<tr><td><span class="STYLE10">arrayLength</span></td>
<td><span class="STYLE10">1000</span></td>
<td><span class="STYLE10">arrayLength</span></td>
<td><span class="STYLE9"></span></td></tr></table>
EOF1
while read line; do
case $((i++ % 3)) in
3) echo -n "$s";;
esac
done<report.html
cat <<EOF2 >> report.html
<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333">
<tr><td rowspan="5"><span class="STYLE9"><a href=\"$img\"><img src="$ImgPath" /a></span></td></tr></table>
<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333">
<tr><td rowspan="5"><span class="STYLE9"><a href=\"$img\"><img src="$ImgPath" /a></span></td></tr></table>
<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333">
<tr><td rowspan="5"><span class="STYLE9"><a href=\"$img\"><img src="$ImgPath" /a></span></td></tr></table>
<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333">
<tr><td rowspan="5"><span class="STYLE9"><a href=\"$img\"><img src="$ImgPath" /a></span></td></tr></table>
<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333">
<tr><td rowspan="5"><span class="STYLE9"><a href=\"$img\"><img src="$ImgPath" /a></span></td></tr></table>
<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#333333">
<tr><td rowspan="5"><span class="STYLE9"><a href=\"$img\"><img src="$ImgPath" /a></span></td></tr></table>
</html>
EOF2
但插入所有行。
谢谢!
答案 0 :(得分:0)
这里:
case $((i++ % 3)) in
3) echo -n "$s";;
esac
不是你想要的。 i++ % 3
为0,1或2,但从不为3.