Shell技巧 三行并为一行

将以下三行并为一行,并用,号分隔。
mail: [email protected]
mailQuota:
userPassword:: c2VjcmV0
mail: [email protected]
mailQuota:
userPassword:: c2VjcmV0
mail: [email protected]
mailQuota: 10000
userPassword:: e2NyeXB0fWhDM21NNm1zQUtBUXc=
mail: [email protected]
mailQuota: 10000
userPassword:: e2NyeXB0fUtuQW50NEx6TS4zRG8=
mail: [email protected]
mailQuota: 50000
userPassword:: e2NyeXB0fUtuLmVpUTNDTkNUeTI=
 
 
方法一:
awk '{if (NR%3==0) {print} else {printf "%s,",$0}}' aaa
 
mail: [email protected],mailQuota: ,userPassword:: c2VjcmV0
mail: [email protected],mailQuota: ,userPassword:: c2VjcmV0
mail: [email protected],mailQuota: 10000,userPassword:: e2NyeXB0fWhDM21NNm1zQUtBUXc=
mail: [email protected],mailQuota: 10000,userPassword:: e2NyeXB0fUtuQW50NEx6TS4zRG8=
mail: [email protected],mailQuota: 50000,userPassword:: e2NyeXB0fUtuLmVpUTNDTkNUeTI=
 
 
方法2:
sed '/mail:/ !N;s/\n/, /' user.txt  | sed '$!N;s/\n/, /'
 
结果如下:
mail: [email protected], mailQuota: , userPassword:: c2VjcmV0
mail: [email protected], mailQuota: , userPassword:: c2VjcmV0
mail: [email protected], mailQuota: 10000, userPassword:: e2NyeXB0fWhDM21NNm1zQUtBUXc=
mail: [email protected], mailQuota: 10000, userPassword:: e2NyeXB0fUtuQW50NEx6TS4zRG8=
mail: [email protected], mailQuota: 50000, userPassword:: e2NyeXB0fUtuLmVpUTNDTkNUeTI=
mail: [email protected], mailQuota: 10000, userPassword:: e2NyeXB0fXdWN25HdFAzVHlQU2M=
 
方法3:
ultraedit32下记录宏和执行宏。
 

你可能感兴趣的:(职场,休闲)