我从mu shell promt执行以下mysql查询
/usr/local/mysql/bin/mysql -u root -p -H -e 'show processlist;' > test.html
所以现在html文件的表格如下所示
<TABLE BORDER=1>
<TR>
<TH>Id</TH>
<TH>User</TH>
<TH>Host</TH>
<TH>db</TH>
<TH>Command</TH>
<TH>Time</TH>
<TH>State</TH>
<TH>Info</TH>
</TR>
<TR>
<TD>1</TD>
<TD>root</TD>
<TD>localhost</TD>
<TD>NULL</TD>
<TD>Sleep</TD>
<TD>1357</TD>
<TD></TD>
<TD>NULL</TD>
</TR>
<TR>
<TD>7</TD>
<TD>root</TD>
<TD>localhost</TD>
<TD>NULL</TD>
<TD>Query</TD>
<TD>0</TD>
<TD>NULL</TD>
<TD>show processlist</TD>
</TR>
</TABLE>
这意味着它只保存为一行,但我需要在一行中按每个<tr></tr>
进行如下操作
<TABLE BORDER=1>
<TR>
<TH>Id</TH>
<TH>User</TH>
<TH>Host</TH>
<TH>db</TH>
<TH>Command</TH>
<TH>Time</TH>
<TH>State</TH>
<TH>Info</TH>
</TR>
<TR>
<TD>1</TD>
<TD>root</TD>
<TD>localhost</TD>
<TD>NULL</TD>
<TD>Sleep</TD>
<TD>1357</TD>
<TD></TD>
<TD>NULL</TD>
</TR>
<TR>
<TD>7</TD>
<TD>root</TD>
<TD>localhost</TD>
<TD>NULL</TD>
<TD>Query</TD>
<TD>0</TD>
<TD>NULL</TD>
<TD>show processlist</TD>
</TR>
</TABLE>
尝试使用sed命令