我尝试使以下脚本并行失败。这里的诀窍是什么?此脚本一次在文件的一列上运行。我想并行处理许多列。
这是顺序脚本。它正确返回值1,因为这是CSV文件的第11列中有多少个非数字:
$ tail -n +2 beerdirty.csv | cut -d, -f 11 | awk -F"," '(($1+0 != $1) && ($1!="")){cnt++} END{print cnt+0}'
1
这是我在gnu parallel上失败的尝试。我只想要seq中的整数进入cut -f参数。也许引用字符有问题:
$ seq 1 12 | parallel 'tail -n +2 beerdirty.csv | cut -d, -f {} | awk -F"," "(($1+0 != $1) && ($1!="")){cnt++} END{print cnt+0}"'
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
awk: line 1: syntax error at or near )
谢谢
答案 0 :(得分:1)
未测试:
doit() {
tail -n +2 beerdirty.csv |
cut -d, -f $1 |
awk -F"," '(($1+0 != $1) && ($1!="")){cnt++} END{print cnt+0}'
}
export -f doit
seq 1 12 | parallel doit