我想在我的awk代码中将mystatus shell变量更新为新值。 但我猜的语法是不正确的,也 我曾尝试申报或EVAL,但没有任何工程 您好,请帮我这个更改AWK条件块内的Shell脚本变量值
我的代码:
mystatus="resolved" -- shell variable
awk 'BEGIN { print "<table>" } -- awk code to write in new file
{
print "<tr><td>" $1 "</td><td>" $2 "</td><tr>"
if ($1=="stopped") mystatus="problem" -- change shell variable value
}
END { print "</table>" }' filestats.txt > email.html
echo $mystatus -- variabe value not getting changed.
你不能以这种方式更改shell变量。将其写入awk中的文件并将其读取到shell中的变量中。 –