AWK语法错误 - 导致它的原因是什么?

use*_*818 3 bash awk

我有简单的bash脚本:

#!/bin/sh
column=${1:-1}
awk ' {colawk='$column'+2; print $colawk}'
awk '(x=4; print $x)'
Run Code Online (Sandbox Code Playgroud)

但是我收到了错误:

awk: (x=4; print $x)
awk:     ^ syntax error
awk: cmd. line:1: (x=4; print $x)
awk: cmd. line:1:                ^ unexpected newline or end of string
Run Code Online (Sandbox Code Playgroud)

为什么?上一行中的代码有效.

kev*_*kev 5

AWK程序是一系列模式动作对,写作如下:

condition { action }
Run Code Online (Sandbox Code Playgroud)

where condition通常是表达式,action是一系列命令.

print不是表达式而是语句,因此它是预期的语法错误.