After doing a lot of home work and running multiple test scenarios, I decided to get help from experts
Here is my scenario
Input data after sorting by Column 1
-bash-3.2$ sort -t'|' -k1 -k2 clm.srt "1033CLMS0400000000000"||""|"0000000558 "| |1 "2020000005438WC011631"||""|" 200606202"| |2 "2020000005438WC011632"|10|"N"|"20060626N00000200000"|10 |3 "2020000005438WC011632"|11|"N"|"20060626N00000200000"|11 |4 "2020000005438WC011632"|12|"N"|"20060626N00000200000"|12 |5 "2020000005438WC011632"|1|"N"|"20060620N000020000000"|1 |13 "2020000005438WC011632"|47|"N"|"20060626N00000000000"|47 |43 "2020000005438WC011632"|5|"N"|"20060626N000000000000"|5 |45 "2020000005438WC011632"|6|"N"|"20060626N0002N0200000"|6 |46 "2020000005438WC011632"|7|"N"|"20060626N000002N00000"|7 |47 "2020000005438WC011632"|8|"N"|"20060626N000000200000"|8 |48 "2020000005438WC011632"|9|"N"|"20060626N0000N0200000"|9 |49 "2020000005438WC011633"||""|"20060605000 "| |50 "2020000005438WC011634"||""|"001033720061 "| |51 "2020000005438WC011635"||""|"0020060626N+00014000000"| |52
If I force numeric sort on 2nd field, blank values are pushed to top, this disturbs my first field sort
-bash-3.2$ sort -t'|' -k1 -n -k2 clm.srt "1033CLMS0400000000000"||""|"0000000558 "| |1 "2020000005438WC011631"||""|" 200606202"| |2 "2020000005438WC011633"||""|"20060605000 "| |50 "2020000005438WC011634"||""|"001033720061 "| |51 "2020000005438WC011635"||""|"0020060626N+00014000000"| |52 "2020000005438WC011632"|1|"N"|"20060620N000020000000"|1 |13 "2020000005438WC011632"|5|"N"|"20060626N000000000000"|5 |45 "2020000005438WC011632"|6|"N"|"20060626N0002N0200000"|6 |46 "2020000005438WC011632"|7|"N"|"20060626N000002N00000"|7 |47 "2020000005438WC011632"|8|"N"|"20060626N000000200000"|8 |48 "2020000005438WC011632"|9|"N"|"20060626N0000N0200000"|9 |49 "2020000005438WC011632"|10|"N"|"20060626N00000200000"|10 |3 "2020000005438WC011632"|11|"N"|"20060626N00000200000"|11 |4 "2020000005438WC011632"|12|"N"|"20060626N00000200000"|12 |5 "2020000005438WC011632"|47|"N"|"20060626N00000000000"|47 |43
Ideally I was trying to acheive this
"1033CLMS0400000000000"||""|"0000000558 "| |1 "2020000005438WC011631"||""|" 200606202"| |2 "2020000005438WC011632"|1|"N"|"20060620N000020000000"|1 |13 "2020000005438WC011632"|5|"N"|"20060626N000000000000"|5 |45 "2020000005438WC011632"|6|"N"|"20060626N0002N0200000"|6 |46 "2020000005438WC011632"|7|"N"|"20060626N000002N00000"|7 |47 "2020000005438WC011632"|8|"N"|"20060626N000000200000"|8 |48 "2020000005438WC011632"|9|"N"|"20060626N0000N0200000"|9 |49 "2020000005438WC011632"|10|"N"|"20060626N00000200000"|10 |3 "2020000005438WC011632"|11|"N"|"20060626N00000200000"|11 |4 "2020000005438WC011632"|12|"N"|"20060626N00000200000"|12 |5 "2020000005438WC011632"|47|"N"|"20060626N00000000000"|47 |43 "2020000005438WC011633"||""|"20060605000 "| |50 "2020000005438WC011634"||""|"001033720061 "| |51 "2020000005438WC011635"||""|"0020060626N+00014000000"| |52
Please suggest
Regards Suresh
Aucun commentaire:
Enregistrer un commentaire