1
下面的命令是錯誤的,關鍵是我想使用AWK $curLineNumber
,我該怎麼辦呢?任何解決方案
curLineNumber = 3
curTime=`ls -l | awk 'NR==$curLineNumber {print $NF}'`
由於
下面的命令是錯誤的,關鍵是我想使用AWK $curLineNumber
,我該怎麼辦呢?任何解決方案
curLineNumber = 3
curTime=`ls -l | awk 'NR==$curLineNumber {print $NF}'`
由於
curTime=$(ls -l | awk -v line=$curLineNumber 'NR == line { print $NF }'
的-v
選項用於指定在命令行上初始化的變量。我爲awk
變量選擇了名稱line
。