【发布时间】:2021-07-30 21:05:14
【问题描述】:
我的 output.txt 文件有两列。我正在尝试添加 HTML 代码来更改将显示数据的单元格的背景颜色。如果该值大于 70,我将添加红色背景颜色并将该值与其对应的主机名一起保存在 .csv 文件中。但是,以下代码无法按要求正常工作。我应该编写什么代码,以便将值及其对应的主机名保存在 .csv 文件中??
Output.txt file:
Hostname, Value
POIDAPP1122,60
POIMAPP150,68
PSSBLEA072,66
PSSBLEA073,65
PSSBLEMA041,66
PSSBLEMA104,60
POIDAPP2120,68
POIMAPP149,60
POAMAPP1121,61
PSSBLEA111,60
PSSBLEAIW133,67
PSSBLEAIW143,61
PSSBLSSOOAMA076,64
PSSBLSSOOIMA200,68
plsbproxyw123,61
for i in `cat $path/output.txt| sed "1 d"`; do
Shostname=$(echo $i |awk '{print $1}');
Svalue=$(echo $i |awk '{print $2}');
if [ $Svalue -gt 70 ]
then
echo "Shostname,<div class="c1">$Svalue" >>$path/output_new.csv
elif [ $Svalue -gt 65 ]
then
echo "$Shostname,<div class="w1">$Svalue" >>$path/output_new.csv
then
echo "$Shostname,$Svalue" >>$path/output_new.csv
fi
done
Getting this output:
HOSTNAME, SPACE(%)
66 66
66 66
67 67
68 68
68 68
68 68
65
65
65
65
65
65
65
PSSBLEA073 66
PSSBLEA072 66
PSSBLEMA041 66
PSSBLEAIW133 66
PSSBLSSOOIMA200 66
POIDAPP2120 66
POIMAPP150 66
PSSBLEA073 66
PSSBLEA072 66
PSSBLEMA041 66
PSSBLEAIW133 66
PSSBLSSOOIMA200 66
POIDAPP2120 66
POIMAPP150 66
PSSBLEA073 67
PSSBLEA072 67
PSSBLEMA041 67
PSSBLEAIW133 67
PSSBLSSOOIMA200 67
POIDAPP2120 67
POIMAPP150 67
PSSBLEA073 68
PSSBLEA072 68
PSSBLEMA041 68
PSSBLEAIW133 68
PSSBLSSOOIMA200 68
POIDAPP2120 68
POIMAPP150 68
PSSBLEA073 68
PSSBLEA072 68
PSSBLEMA041 68
PSSBLEAIW133 68
PSSBLSSOOIMA200 68
POIDAPP2120 68
POIMAPP150 68
PSSBLEA073 68
PSSBLEA072 68
PSSBLEMA041 68
PSSBLEAIW133 68
PSSBLSSOOIMA200 68
POIDAPP2120 68
POIMAPP150 68
PSSBLEA073 65
PSSBLEA072 66
PSSBLEMA041 66
PSSBLEAIW133 67
PSSBLSSOOIMA200 68
POIDAPP2120 68
POIMAPP150 68
This is my desired output:
HOSTNAME SPACE(%)
PSSBLEA073 65
PSSBLEA072 66
PSSBLEMA041 66
PSSBLEAIW133 67
PSSBLSSOOIMA200 68
POIDAPP2120 68
POIMAPP150 68
【问题讨论】: