行转列
1、#cata.txt
codeAref1
codeBref3
codeArex5
codeBrex2
输出格式为:
codeA
ref:1
rex:5
codeB
rex:2
ref:3
方法一、
cata.txt|sort+0-1+2n|awk'{print$1,$2":"$3}'|awk'{a[$1]=a[$1]?a[$1]"\n"$2:$1"\n"$2}END{for(iina)printa[i]}'
方法二、
catb.txt|sort+0-1+2nr|awk'{print$1,$2":"$3}'|awk'{print$1,$2":"$3}'|awk'{if(!a[$1]++){print$1"\n"$2;}else{print$2}}'
方法三、
catb.txt|sort+0-1+2nr|awk'{print$1,$2":"$3}'|awk'{print$1==i?$2:$1RS$2;i=$1}'
2、行转列
oracle@/opt/oracle/zch:~>cat3.txt
111
222
333
444
555
666
777
oracle@/opt/oracle/zch:~>awk'BEGIN{printf""}{printf$1""}END{printf""}'3.txt
111222333444555666777oracle@/opt/oracle/zch:~>
相关推荐
chenpro 2020-07-04
fendou00sd 2020-06-16
RealJianyuan 2020-06-14
cwgxiaoguizi 2020-06-05
chenpro 2020-06-02
Neptune 2020-05-31
老谢的自留地 2020-05-09
YukiRain 2020-05-08
baobaozai 2020-04-29
Proudoffaith 2020-04-08
fenxinzi 2020-03-01
zhiliang 2020-01-31
wannagonna 2020-01-13
wandererdl 2019-12-25
chenchuang 2020-01-25
jyj00 2020-01-09
fendou00sd 2020-01-07
fendou00sd 2020-01-06
PHP学习笔记 2020-01-06