I have a file with semicolon separated fields, which I want to sort according to general numeric value of the 26th column. I tried this:cat file.txt | grep -v setch | sort -t; -k26 -gThe grep command is there to filter out some lines I don't want. The file after the grep command looks like this:5;0;0;0;0;17;0.040000;3.00;17;0.030000;2.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;;;;;;;33.15;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.020000;3.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.18901342e+02;-7.78309691e+01;-7.78225676e+01;-7.78079745e+01;-7.77838466e+01;;39.3333333333333;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.020000;20.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.78309996e+01;-7.78285783e+01;-7.78259409e+01;-7.78212922e+01;-7.78200550e+01;;39.8166666666667;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.030000;3.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-9.38492178e+02;-5.44898488e+02;-7.78311132e+01;-7.78228037e+01;-7.78082194e+01;;40.6166666666667;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.030000;8.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.78321216e+01;-7.78265847e+01;-7.78213151e+01;-7.78175760e+01;-7.78102439e+01;;40.4833333333333;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.030000;15.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.78326108e+01;-7.78282041e+01;-7.78246496e+01;-7.78216823e+01;-7.78198536e+01;;40.0333333333333;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.020000;15.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.78317280e+01;-7.78275891e+01;-7.78237230e+01;-7.78209144e+01;-7.78197521e+01;;44.3;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.030000;10.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.78322942e+01;-7.78274590e+01;-7.78225495e+01;-7.78192915e+01;-7.78148301e+01;;43.65;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.020000;8.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.78322863e+01;-7.78266434e+01;-7.78211618e+01;-7.78173451e+01;-7.78097348e+01;;45.4833333333333;;X;;E;5;0;0;0;0;17;0.040000;3.00;17;0.030000;4.00;17;0.040000;7.00;11.5833330154419;11.5833330154419;11.5833330154419;0.522556364536285;312.500000000000;-1384.20000000000;39.0625000000000;6000.00000000000;;;;-7.61265100e+02;-7.78321802e+01;-7.78247066e+01;-7.78104129e+01;-7.78053976e+01;;44.8833333333333;;X;;E;The output is however not sorted according to general numerical value, but according to numerical value (without reference to the powers). Is there anything I can do to get sort to do what I want?Update: This is the output of the above pipe (only the relevant column shown), and it is also the output of sort -t\; -g -k26,26, which was suggested in the answer. -9.38492178e+02-7.78317280e+01-7.78309996e+01-7.18901342e+02-7.78322863e+01-7.78322942e+01-7.78326108e+01 -7.61265100e+02-7.78321216e+01
sort behaves weirdly with scientific notation
sort
note the difference in output between these two pipelines:<yourexample \sort -t\; -gk26 |cut -d\; -f26-7.18901342e+02-7.78309996e+01-9.38492178e+02-7.78321216e+01-7.78326108e+01-7.78317280e+01-7.78322942e+01-7.78322863e+01-7.61265100e+02...and...<yourexample \sort -t\; -gk26,26 |cut -d\; -f26-9.38492178e+02-7.61265100e+02-7.18901342e+02-7.78326108e+01-7.78322942e+01-7.78322863e+01-7.78321216e+01-7.78317280e+01-7.78309996e+01sorting just on -key 26 is the same as sorting from key 26 through to the end of the line, but sorting on -key 26,26 sorts only on that key. if you want to consider other fields in the sort order as tie breakers, add more -keys - but be specific.All that aside, you've commented that you're working with a 5-year-old GNU Coreutils package. Curious, I skipped through a few changelogs after your release, and this stood out within two releases (Oct 2010 for v8.6):sort -g now uses long doubles for greater range and precision.sort -h no longer rejects numbers with leading or trailing ., and no longer accepts numbers with multiple ..  It now considers all zeros to be equal.You might update.