- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2014-03-24 14:29 编辑
回复 1# su8610
How about this way
# cat FILE
a,"testline # c = 0, NF =2(oven) , combine data to d, and assign NF to c
newline",here # c = 1, NF =2(oven) , check here in tail
b,test2,not-here # c = 0, NF =1(odd), check here in tail
c,aas,here # c = 0, NF =1(odd), check here in tail
b,sdaasd,here # c = 0, NF =1(odd), check here in tail
e,teste,here-no # c = 0, NF =1(odd), check here in tail
# awk -F'"' '{d=d==""?$0:d"\n"$0;if((NF+c)%2==0){c=1;next};if(/,here$/)print d;d=c=""}' FILE
a,"testline
newline",here
c,aas,here
b,sdaasd,here
|
|