I'm trying to sort on multiple columns a file with GNU sort.The format of the source file tmp/file.txt is :03A12345679   2014-09-30-00.00.01.0003 => first columnA => field separator 12345679    => second column 2014-09-30-00.00.01.00 => other column (not sorted)I've tried this command :sort --field-separator=A -k2,11 -k1,2 tmp/file.txt > tmp/file_out.txtWith :--field-separator=A => field separator is A -k2,11 => the second column is the first sort (12345679   )-k1,2 => the first column is the second sort (03)But in the result the sort is not correct (the 03 is before the 01 and 02 lines) :03A12345679   2014-09-30-00.00.01.000000-000001A12345679   12345679  132132155VDVLDLV02A12345679   FONDSEURO   000012664,120000000M02A12345679   FR09999956570000009999,999990000F01A12345680   47295851959860120000000004729582402A12345680   122121EUR     0000099999,370000000MI want to have this result :01A12345679   12345679  132132155VDVLDLV02A12345679   FONDSEURO   000012664,120000000M02A12345679   FR09999956570000009999,999990000F03A12345679   2014-09-30-00.00.01.000000-000001A12345680   47295851959860120000000004729582402A12345680   122121EUR     0000099999,370000000MHow can i do that ?
Trying to sort on two fields first is second criteria
sort
You seem to be mixing up field positions and character positions. There is no need to split on A; with GNU sort, you can sort on a range of characters within the first space-delimited field:$ sort -k1.4,1.11 -k1.1,1.2 file01A12345679   12345679  132132155VDVLDLV02A12345679   FONDSEURO   000012664,120000000M02A12345679   FR09999956570000009999,999990000F03A12345679   2014-09-30-00.00.01.000000-000001A12345680   47295851959860120000000004729582402A12345680   122121EUR     0000099999,370000000M