Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [DE] sort Problem  (Read 7485 times)

Offline bluelupo

  • User
  • Posts: 2.068
    • BluelupoMe
[DE] sort Problem
« on: 2013/07/03, 22:02:54 »
Hallo zusammen,
ich möchte mit einem Shellscript eine Liste der Kernel sortieren, die Liste sieht so aus VOR dem sortieren:

Code: [Select]

linux-image-3.10-0.towo-siduction-amd64 03-Jul-2013 12:19
linux-image-3.4-5.towo-siduction-amd64 17-Jul-2012 10:55
linux-image-3.5-2.towo-siduction-amd64 18-Aug-2012 12:50
linux-image-3.5-3.towo-siduction-amd64 30-Aug-2012 21:10
linux-image-3.5-4.towo-siduction-amd64 15-Sep-2012 18:20
linux-image-3.5-4.towo.1-siduction-amd64 29-Sep-2012 20:45
linux-image-3.6-0.towo-siduction-amd64 01-Oct-2012 15:00
linux-image-3.6-1.towo-siduction-amd64 08-Oct-2012 18:35
linux-image-3.6-10.towo-siduction-amd64 10-Dec-2012 21:55
linux-image-3.6-2.towo-siduction-amd64 15-Oct-2012 09:45
linux-image-3.6-3.towo-siduction-amd64 26-Oct-2012 16:05
linux-image-3.6-4.towo-siduction-amd64 28-Oct-2012 21:35
linux-image-3.6-5.towo-siduction-amd64 31-Oct-2012 20:25
linux-image-3.6-6.towo-siduction-amd64 18-Nov-2012 18:20
linux-image-3.6-7.towo-siduction-amd64 22-Nov-2012 09:20
linux-image-3.6-8.towo-siduction-amd64 27-Nov-2012 23:40
linux-image-3.6-9.towo-siduction-amd64 07-Dec-2012 12:30
linux-image-3.7-0.towo-siduction-amd64 15-Dec-2012 14:20
linux-image-3.7-1.towo-siduction-amd64 11-Jan-2013 22:35
linux-image-3.7-2.towo-siduction-amd64 12-Jan-2013 15:10
linux-image-3.7-3.towo-siduction-amd64 19-Jan-2013 19:20
linux-image-3.7-3.towo.1-siduction-amd64 20-Jan-2013 14:30
linux-image-3.7-4.towo-siduction-amd64 22-Jan-2013 09:35
linux-image-3.7-5.towo-siduction-amd64 28-Jan-2013 13:25
linux-image-3.7-5.towo.1-siduction-amd64 01-Feb-2013 13:35
linux-image-3.7-6.towo-siduction-amd64 04-Feb-2013 10:05
linux-image-3.7-7.towo-siduction-amd64 11-Feb-2013 22:20
linux-image-3.7-8.towo-siduction-amd64 15-Feb-2013 12:00
linux-image-3.7-9.towo-siduction-amd64 18-Feb-2013 12:15
linux-image-3.8-0.towo-siduction-amd64 19-Feb-2013 10:35
linux-image-3.8-0.towo.1-siduction-amd64 26-Feb-2013 15:35
linux-image-3.8-1.towo-siduction-amd64 28-Feb-2013 18:50
linux-image-3.8-1.towo.1-siduction-amd64 02-Mar-2013 18:35
linux-image-3.8-2.towo-siduction-amd64 04-Mar-2013 10:10
linux-image-3.8-3.towo-siduction-amd64 16-Mar-2013 11:00
linux-image-3.8-3.towo.1-siduction-amd64 19-Mar-2013 10:05
linux-image-3.8-4.towo-siduction-amd64 21-Mar-2013 11:35
linux-image-3.8-5.towo-siduction-amd64 29-Mar-2013 18:05
linux-image-3.8-6.towo-siduction-amd64 06-Apr-2013 17:16
linux-image-3.8-7.towo-siduction-amd64 12-Apr-2013 23:44
linux-image-3.8-8.towo-siduction-amd64 18-Apr-2013 09:35
linux-image-3.8-9.towo-siduction-amd64 26-Apr-2013 08:45
linux-image-3.9-0.towo-siduction-amd64 29-Apr-2013 10:58
linux-image-3.9-0.towo.2-siduction-amd64 07-May-2013 15:11
linux-image-3.9-1.towo-siduction-amd64 09-May-2013 16:24
linux-image-3.9-2.towo-siduction-amd64 18-May-2013 13:04
linux-image-3.9-2.towo.2-siduction-amd64 18-May-2013 14:07
linux-image-3.9-3.towo-siduction-amd64 20-May-2013 11:29
linux-image-3.9-4.towo-siduction-amd64 25-May-2013 17:58
linux-image-3.9-4.towo.1-siduction-amd64 06-Jun-2013 11:05
linux-image-3.9-5.towo-siduction-amd64 08-Jun-2013 17:11
linux-image-3.9-5.towo.1-siduction-amd64 12-Jun-2013 11:09
linux-image-3.9-6.towo-siduction-amd64 13-Jun-2013 21:23
linux-image-3.9-6.towo.1-siduction-amd64 18-Jun-2013 21:23
linux-image-3.9-7.towo-siduction-amd64 21-Jun-2013 18:16
linux-image-3.9-8.towo-siduction-amd64 28-Jun-2013 23:15


Nach dem sortieren stimmt sie schon fast...
Code: [Select]

sort -t"-" -n -k3,4 kernel.txt

linux-image-3.4-5.towo-siduction-amd64 17-Jul-2012 10:55
linux-image-3.5-2.towo-siduction-amd64 18-Aug-2012 12:50
linux-image-3.5-3.towo-siduction-amd64 30-Aug-2012 21:10
linux-image-3.5-4.towo.1-siduction-amd64 29-Sep-2012 20:45
linux-image-3.5-4.towo-siduction-amd64 15-Sep-2012 18:20
linux-image-3.6-0.towo-siduction-amd64 01-Oct-2012 15:00
linux-image-3.6-10.towo-siduction-amd64 10-Dec-2012 21:55
linux-image-3.6-1.towo-siduction-amd64 08-Oct-2012 18:35
linux-image-3.6-2.towo-siduction-amd64 15-Oct-2012 09:45
linux-image-3.6-3.towo-siduction-amd64 26-Oct-2012 16:05
linux-image-3.6-4.towo-siduction-amd64 28-Oct-2012 21:35
linux-image-3.6-5.towo-siduction-amd64 31-Oct-2012 20:25
linux-image-3.6-6.towo-siduction-amd64 18-Nov-2012 18:20
linux-image-3.6-7.towo-siduction-amd64 22-Nov-2012 09:20
linux-image-3.6-8.towo-siduction-amd64 27-Nov-2012 23:40
linux-image-3.6-9.towo-siduction-amd64 07-Dec-2012 12:30
linux-image-3.7-0.towo-siduction-amd64 15-Dec-2012 14:20
linux-image-3.7-1.towo-siduction-amd64 11-Jan-2013 22:35
linux-image-3.7-2.towo-siduction-amd64 12-Jan-2013 15:10
linux-image-3.7-3.towo.1-siduction-amd64 20-Jan-2013 14:30
linux-image-3.7-3.towo-siduction-amd64 19-Jan-2013 19:20
linux-image-3.7-4.towo-siduction-amd64 22-Jan-2013 09:35
linux-image-3.7-5.towo.1-siduction-amd64 01-Feb-2013 13:35
linux-image-3.7-5.towo-siduction-amd64 28-Jan-2013 13:25
linux-image-3.7-6.towo-siduction-amd64 04-Feb-2013 10:05
linux-image-3.7-7.towo-siduction-amd64 11-Feb-2013 22:20
linux-image-3.7-8.towo-siduction-amd64 15-Feb-2013 12:00
linux-image-3.7-9.towo-siduction-amd64 18-Feb-2013 12:15
linux-image-3.8-0.towo.1-siduction-amd64 26-Feb-2013 15:35
linux-image-3.8-0.towo-siduction-amd64 19-Feb-2013 10:35
linux-image-3.8-1.towo.1-siduction-amd64 02-Mar-2013 18:35
linux-image-3.8-1.towo-siduction-amd64 28-Feb-2013 18:50
linux-image-3.8-2.towo-siduction-amd64 04-Mar-2013 10:10
linux-image-3.8-3.towo.1-siduction-amd64 19-Mar-2013 10:05
linux-image-3.8-3.towo-siduction-amd64 16-Mar-2013 11:00
linux-image-3.8-4.towo-siduction-amd64 21-Mar-2013 11:35
linux-image-3.8-5.towo-siduction-amd64 29-Mar-2013 18:05
linux-image-3.8-6.towo-siduction-amd64 06-Apr-2013 17:16
linux-image-3.8-7.towo-siduction-amd64 12-Apr-2013 23:44
linux-image-3.8-8.towo-siduction-amd64 18-Apr-2013 09:35
linux-image-3.8-9.towo-siduction-amd64 26-Apr-2013 08:45
linux-image-3.9-0.towo.2-siduction-amd64 07-May-2013 15:11
linux-image-3.9-0.towo-siduction-amd64 29-Apr-2013 10:58
linux-image-3.9-1.towo-siduction-amd64 09-May-2013 16:24
linux-image-3.9-2.towo.2-siduction-amd64 18-May-2013 14:07
linux-image-3.9-2.towo-siduction-amd64 18-May-2013 13:04
linux-image-3.9-3.towo-siduction-amd64 20-May-2013 11:29
linux-image-3.9-4.towo.1-siduction-amd64 06-Jun-2013 11:05
linux-image-3.9-4.towo-siduction-amd64 25-May-2013 17:58
linux-image-3.9-5.towo.1-siduction-amd64 12-Jun-2013 11:09
linux-image-3.9-5.towo-siduction-amd64 08-Jun-2013 17:11
linux-image-3.9-6.towo.1-siduction-amd64 18-Jun-2013 21:23
linux-image-3.9-6.towo-siduction-amd64 13-Jun-2013 21:23
linux-image-3.9-7.towo-siduction-amd64 21-Jun-2013 18:16
linux-image-3.9-8.towo-siduction-amd64 28-Jun-2013 23:15
linux-image-3.10-0.towo-siduction-amd64 03-Jul-2013 12:19


Nur die Kernel, die nach dem String "towo" noch eine Zahl haben, sind noch nicht korrekt chronologisch einsortiert. Was mache ich hier noch falsch?

Offline ralul

  • User
  • Posts: 1.814
sort Problem
« Reply #1 on: 2013/07/03, 23:33:41 »
sort --key=3,4 --field-separator='-' --numeric-sort
experiencing siduction runs better than my gentoo makes me know I know nothing

Offline bluelupo

  • User
  • Posts: 2.068
    • BluelupoMe
sort Problem
« Reply #2 on: 2013/07/04, 08:18:46 »
Hi ralul,
Danke für deinen Vorschlag, aber genau das hatte ich ja schon probiert. Die chronologische Reihe stimmt bis auf die gekennzeichneteten Fälle:
Code: [Select]

$ sort --key=3,4 --field-separator='-' --numeric-sort kernel.txt
[...]
linux-image-3.9-3.towo-siduction-amd64 20-May-2013 11:29
linux-image-3.9-4.towo.1-siduction-amd64 06-Jun-2013 11:05 <<<<
linux-image-3.9-4.towo-siduction-amd64 25-May-2013 17:58 <<<<
linux-image-3.9-5.towo.1-siduction-amd64 12-Jun-2013 11:09
linux-image-3.9-5.towo-siduction-amd64 08-Jun-2013 17:11
linux-image-3.9-6.towo.1-siduction-amd64 18-Jun-2013 21:23 <<<<
linux-image-3.9-6.towo-siduction-amd64 13-Jun-2013 21:23 <<<<
linux-image-3.9-7.towo-siduction-amd64 21-Jun-2013 18:16
linux-image-3.9-8.towo-siduction-amd64 28-Jun-2013 23:15
linux-image-3.10-0.towo-siduction-amd64 03-Jul-2013 12:19

Offline ralul

  • User
  • Posts: 1.814
sort Problem
« Reply #3 on: 2013/07/04, 11:21:07 »
Falsch:
Code: [Select]

cat Datei|LC_COLLATE=de_DE.utf8 sort --key=3,4 --field-separator='-' --numeric-sort

Richtig:
Code: [Select]

cat Datei|LC_COLLATE=C sort --key=3,4 --field-separator='-' --numeric-sort


LC_ALL hat LC_COLLATE mit drin
experiencing siduction runs better than my gentoo makes me know I know nothing

Offline bluelupo

  • User
  • Posts: 2.068
    • BluelupoMe
sort Problem
« Reply #4 on: 2013/07/04, 14:51:17 »
Hi ralul,
Danke das war's. Nochmal eine Frage zum Verstehen ;-)

LC_COLLATE beeinflusst die alphabetsiche Sortierung von Strings in Abhängigkeit von der gesetzten Sprache ($LANG). Richtig?? Und woher weiß ich wie welche Systemsprache sortiert?