[Email protected] study]#Cat fileZhang San languageBayiZhang San MathematicsBayiJohn Doe Language theJohn Doe Mathematics -Harry LanguageBayiHarry Mathematics -Harry English -How to implement for the following sort??? Bayi Bayi the - Bayi - -Chinese Mathematics Chinese Mathematics Chinese Mathematics English Zhang Sanzhang Harry Harry Harry the following is the thinking analysis: Zhang San ChineseBayiZhang San MathematicsBayiJohn Doe Language theJohn Doe Mathematics -Harry LanguageBayiHarry Mathematics -Harry English - for(i=1; i<=nf;i++) a[nr,i]=$i [NR i]=$ia [1,1]= $i =$1=1a[1,2]= $i =$1=2a[1,3]= $i =$1=3a[2,1]= $i =$1=1a[2,2]= $i =$1=2a[2.3]= $i =$1=3a[3,1]= $i =$1=1a[3,2]= $i =$1=2a[3,3]= $i =$1=3a[4,1]= $i =$1=1a[4,2]= $i =$1=2a[4.3]= $i =$1=3a[5,1]= $i =$1=1a[5,2]= $i =$1=2a[5,3]= $i =$1=3a[6,1]= $i =$1=1a[6,2]= $i =$1=2a[6,3]= $i =$1=3a[7,1]= $i =$1=1a[7,2]= $i =$1=2a[7,3]= $i =$1=3the values of these arrays correspond to the above one by one for the following sortBayi Bayi the - Bayi - -Chinese Mathematics Chinese Mathematics Chinese Mathematics English Zhang Sanzhang Harry Harry Harry then their corresponding array variable is: a[1,3] A[2.3] A[3,3] A[4.3] A[5,3] A[6,3] A[7.3]a[1,2] A[2,2] A[3,2] A[4,2] A[5,2] A[6,2] A[7,2]a[1,1] A[2,1] A[3,1] A[4,1] A[5,1] A[6,1] A[7,1] You can use the 2 for loop to control the corresponding array of the following table to remove the corresponding values for(i=nf;i>=1; i--) Output i=3 2 1(3>i>1) for(j=1; j<=nr;j++) Output j=1 2 3 4 5 6 7(1<j<7) When I= 3 o'clock j=1,2,3,4,5,6,7a[j,i] Output a[1,3] A[2,3] A[3,3] A[4,3] A[5,3] A[6,3] A[7,3] when I= 2 o'clock j=1,2,3,4,5,6,7a[j,i] Output a[1,2] A[2,2] A[3,2] A[4,2] A[5,2] A[6,2] A[7,2] when I= 2 o'clock j=1,2,3,4,5,6,7a[j,i] Output a[1,1] A[2,1] A[3,1] A[4,1] A[5,1] A[6,1] A[7,1][[email protected] study]#Cat file|awk '{for (i=1;i<=nf;i++) a[nr,i]= $i}end{for (i=nf;i>=1;i--) {for (j=1;j<=nr;j++) {printf a[j,i] ""}print Xxoo} }'Bayi Bayi the - Bayi - -Chinese Mathematics Chinese Mathematics Chinese Mathematics English Zhang Sanzhang Harry Harry Harry
Shell script, awk implements row and column conversions