当前位置: 动力学知识库 > 问答 > 编程问答 >

grep - Using awk to get next fields

问题描述:

I have this input file (space is the separator for the two elements in the line otherwise there is just one element)

a:1

a:1 123

b:2 345

c:3 456

d:4

d:4 456

..

..

I am interested in the output to be

a:1 123

d:4 456

i.e lines which have the preceding field to have just one field.

网友答案:

Try this:

 { if (NF == 1) { getline; print; next; } }
分享给朋友:
您可能感兴趣的文章:
随机阅读: