一个awk的内部多个命令 [英] multiple commands inside a awk
问题描述
SRY打开一个新的线程,但AWK我发疯! ><我尝试运行单个AWK里面的几个命令任务,但我不能让它的工作请帮助,如果这是EZ为U:P I不能得到语法工作
sry opening a new thread but awk is driving me nuts! >< im trying to run a few command assignments inside a single awk but i cant get it to work please help if this is ez for u :P i can't get the syntax to work
编辑:即时通讯使用/斌/ bash的
edit: im using /bin/bash
for f in `seq $nlinpE $loopE`;
do
awk -F ","'
BEGIN {}
'$f' { dataI2[$f]=$2;
dataI3[$f]=$3;
dataI4[$f]=$4;
noD1[$f]=$dataI1[$f];
noD2[$f]=$dataI2[$f];
noD3[$f]=$dataI3[$f];
noD1i[$f]=`echo "$nlinpN1 + $dataI1"|bc -l`;
noD2i[$f]=`echo "$nlinpN1 + $dataI2"|bc -l`;
noD3i[$f]=`echo "$nlinpN1 + $dataI3"|bc -l`;
}
'${noD1i[$f]}' {
dataIi2[$f]=$2;
dataIi3[$f]=$3;
dataIi4[$f]=$4;
}
'${noD2i[$f]}' {
dataIii2[$f]=$2;
dataIii3[$f]=$3;
dataIii4[$f]=$4;
}
'${noD2i[$f]}' {
dataIiii2[$f]=$2;
dataIiii3[$f]=$3;
dataIiii4[$f]=$4;
}
END{}
' <aoa_5.inp;
完成
输入,如:
17, 3.22854114, 0.562598288, 0.384291202
18, 2.96085286, 0.085116826, 0.285071939
19, 3.40070796, 2.27838659, 0.302027524
20, 3.20035744, 0.333615214, 0.262585849
21, 2.85644341, 0.258691043, 0.369726121
22, 3.73537922, 1.3267405, 0.295917094
23, 3.69372559, 1.32601321, 0.306054831
24, 3.28857207, 0.63199228, 0.378117412
25, 3.27523994, 0.695856452, 0.377585977
imjust分配变量大气压,得到了数W / O逗号结果
我得到这个错误语法类型:
imjust assigning variables atm, getting the number w/o commas
i get this syntax type of error:
awk: 9: unexpected character '`'
awk: 10: unexpected character '`'
awk: 11: unexpected character '`'
(standard_in) 2: syntax error
(standard_in) 2: syntax error
awk: line 1: syntax error at or near {
^C
THX
推荐答案
也许这将帮助你清理你的语法一点,所以我们能理解你想要做的事。
Maybe this will help you clean up your syntax a little so we can understand what you're trying to do.
BEGIN和END块是可选的。忽略模式的时刻,一个awk程序可能是这样的。
BEGIN and END blocks are optional. Ignoring patterns for the moment, an awk program might look like this.
BEGIN {
# Things to be done before you start processing rows.
}
{
# Things to be done for each row.
}
END {
# Things to be done after processing the last row.
}
如果你不碰巧需要开始或终止块,它可能看起来更像这一点。
If you don't happen to need BEGIN or END blocks, it might look more like this.
{
# Things to be done for each row.
}
这awk程序指定的$ 2,$ 3和$ 4变量达泰值,一旦它打印的每一行。
This awk program assigns the value of $2, $3, and $4 to the variable dataI, and prints it once for each row.
{
dataI = sprintf("%s %s %s", $2, $3, $4);
print dataI;
}
这是分配有$ 2,$ 3和$ 4中的值没有任何影响。
That assignment has no effect on the values of $2, $3, and $4.
这篇关于一个awk的内部多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!