agc*_*agc 5 text-processing miller
给定file.csv:
a,b,c
1,2,3
Run Code Online (Sandbox Code Playgroud)
如何mlr
输出:
a,b,c
1,2,c
Run Code Online (Sandbox Code Playgroud)
使用预先$c
不知道$c
包含字母“ c ”的标签名称?
注意:正确答案mlr
只能使用。
编辑答案
你好,你可以使用这个脚本
mlr --csv put 'if (NR == 1) {
counter=1;
for (key in $*) {
if (counter == 3) {
$[key]=key;
}
counter += 1;
}
}' input.csv
Run Code Online (Sandbox Code Playgroud)
作为输出,您将拥有:
a,b,c
1,2,c
Run Code Online (Sandbox Code Playgroud)
NR == 1
获得第一行,并counter == 3
获得第三个字段。