0
的值,我需要用awk分配到一个变量的值:分配在一个变量
$ echo "hello world" | awk -v x=substr($0,3,4) '{print $x}'
-bash: syntax error near unexpected token `('
这里有什么错?
的值,我需要用awk分配到一个变量的值:分配在一个变量
$ echo "hello world" | awk -v x=substr($0,3,4) '{print $x}'
-bash: syntax error near unexpected token `('
这里有什么错?
我想你想要做的是
$ echo "hello world" | awk '{print substr($0,3,4)}'
llo
SUBSTR在awk脚本一个awk功能,仅可(引号内)
或者,将其分配给一个变量
$ awk -v x='hello world' 'BEGIN{print substr(x,3,4)}'
llo