0

the following is file example

585.3 M   netG ple jdhe jdhe_daily se 1732 pcv DC month 202204 day 20220413
585.5 M   netG ple jdhe jdhe_daily se 1734 pcv DC month 202204 day 20220413
585.8 M   netG ple jdhe jdhe_daily se 1733 pcv DC month 202204 day 20220413
585.9 M   netG ple jdhe jdhe_daily se 1731 pcv DC month 202203 day 20220304
586.1 M   netG ple jdhe jdhe_daily se 1732 pcv DC month 202203 day 20220304
586.5 M   netG ple jdhe jdhe_daily se 1735 pcv DC month 202204 day 20220413
587.1 M   netG ple jdhe jdhe_daily se 1734 pcv DC month 202203 day 20220304
587.3 M   netG ple jdhe jdhe_daily se 1733 pcv DC month 202203 day 20220304
587.4 M   netG ple jdhe jdhe_daily se 1736 pcv DC month 202204 day 20220413
587.4 M   netG ple jdhe jdhe_daily se 1737 pcv DC month 202204 day 20220413
587.7 M   netG ple jdhe jdhe_daily se 1738 pcv DC month 202204 day 20220413
588.0 M   netG ple jdhe jdhe_daily se 1735 pcv DC month 202203 day 20220304
594.3 M   netG ple jdhe jdhe_daily se 1730 pcv DC month 202205 day 20220515
594.3 M   netG ple jdhe jdhe_daily se 1737 pcv DC month 202203 day 20220303

we want to sort the date on the last field from old date to new date

dose sort command support to sort numbers according to last field?

1
  • 1
    No, you cannot define 'the last field' with sort. Only if you know the fields number, if it's always 14 fields, you can use -k14.
    – thanasisp
    Commented May 17, 2022 at 10:46

1 Answer 1

0
sort -k 14b,14 file

sort by the 14th column

2
  • Note that sort -k14 defines one sort key that start with the 14th field (fields being delimited by default by the transition between a non-blank and a blank) and ends at the end of the line. To sort by the 14th column, you'd need sort -k 14b,14 with key here starting with the 14th field, leading blanks trimmed and ending with the 14th field. Commented May 17, 2022 at 13:01
  • @Stéphane Chazelas, thanks I will edit the answer. Commented May 17, 2022 at 13:24

Not the answer you're looking for? Browse other questions tagged .