1、现有测试数据如下:
cat a.txt
hadoop1
1
hadoop2
2
hadoop3
3
2、期望的格式
hadoop1: 1
hadoop2: 2
hadoop3: 3
3、使用awk
awk '{if(NR%2!=0)ORS=":";else ORS="\n"}1' a.txt
| http://bbs.chinaunix.net/thread-4241658-1-1.html
标签:两行,ORS,一行,hadoop2,hadoop3,hadoop1,awk,txt
来源: https://www.cnblogs.com/yjt1993/p/14262597.html