我在比较同一文件的两列然后根据另一列替换一列的值时遇到问题
例如,我的文件是:
name col1 col2
abc no no
xyz yes yes
man no no
wrr no no
Run Code Online (Sandbox Code Playgroud)
在这里,我想检查文件col1中的每个'no'值,我想将col2的值更改为'N/A'
$ awk '$2=="no"{$3="N/A"}1' file
name col1 col2
abc no N/A
xyz yes yes
man no N/A
wrr no N/A
Run Code Online (Sandbox Code Playgroud)