Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
awk:删除字段为空的行?_Awk - Fatal编程技术网

awk:删除字段为空的行?

awk:删除字段为空的行?,awk,Awk,嗨,我有一个数据如下: a b c 1 b c d c d e 6 e r w 第4列中的某些字段为空,我想删除第4列中缺少字段的整行,使其如下所示: a b c 1 c d e 6 我不知道从哪里开始做这件事。有人能帮我吗?谢谢只需使用NF检查字段数即可: $ awk 'NF==4' file a b c 1 c d e 6 要使用此更新文件

嗨,我有一个数据如下:

a    b    c    1
b    c    d    
c    d    e    6
e    r    w    
第4列中的某些字段为空,我想删除第4列中缺少字段的整行,使其如下所示:

a    b    c    1
c    d    e    6

我不知道从哪里开始做这件事。有人能帮我吗?谢谢

只需使用
NF检查字段数即可:

$ awk 'NF==4' file
a    b    c    1
c    d    e    6
要使用此更新文件,请执行以下操作:

awk 'NF==4' file > temp_file && mv temp_file file

另一个
awk

awk '!($4 == "")' yourfile

很高兴读到这个!记住,如果你完成了,你可以接受答案