View previous topic :: View next topic |
Author |
Message |
nillsen Apprentice
Joined: 13 Mar 2004 Posts: 150 Location: /world/eu/ger/sh/nms/
|
Posted: Tue Jun 14, 2005 11:29 am Post subject: [Solved]Wortliste nach Wortlänge sortieren? |
|
|
Hallo Leute,
ich möchte eine plaintext Datei sortieren. In jeder Zeile steht genau ein Wort. Sortiert werden soll nach der länge des Wortes - das kürzeste zuerst, das längste zum Ende. Hat jemand da n Denkansatz für mich? Evtl. was mit sed oder awk??? sort bietet die Option ja nicht
Danke schonmal!
dit: [Solved] hinzugefügt _________________ Also tragt es in die Welt, haut es mit Edding an die Wände.
so lang die dicke Frau noch singt, ist die Oper nicht zu ende.
Last edited by nillsen on Tue Jun 14, 2005 1:00 pm; edited 1 time in total |
|
Back to top |
|
|
Rüpel Guru
Joined: 06 Nov 2002 Posts: 316 Location: Berlin/Germany
|
Posted: Tue Jun 14, 2005 12:28 pm Post subject: |
|
|
was besseres fällt mir jetzt nicht ein:
Code: | for i in $(cat datei); do echo ${#i} $i; done | sort | cut -d ' ' -f 2 |
der trick kommt von der bash: gibt die länge des inhalts von $variable aus.
siehe zum beispiel: > hier < _________________ :wq |
|
Back to top |
|
|
nillsen Apprentice
Joined: 13 Mar 2004 Posts: 150 Location: /world/eu/ger/sh/nms/
|
Posted: Tue Jun 14, 2005 12:59 pm Post subject: |
|
|
Rüpel wrote: | was besseres fällt mir jetzt nicht ein: |
Was bessere brauche ich auch nicht, funktioniert nämlich astrein!
Danke _________________ Also tragt es in die Welt, haut es mit Edding an die Wände.
so lang die dicke Frau noch singt, ist die Oper nicht zu ende. |
|
Back to top |
|
|
Rüpel Guru
Joined: 06 Nov 2002 Posts: 316 Location: Berlin/Germany
|
Posted: Tue Jun 14, 2005 1:54 pm Post subject: |
|
|
_________________ :wq |
|
Back to top |
|
|
Earthwings Bodhisattva
Joined: 14 Apr 2003 Posts: 7753 Location: Germany
|
Posted: Tue Jun 14, 2005 2:48 pm Post subject: |
|
|
Das funktioniert so nur für kurze Worte. Häng als Parameter für sort noch -n an, damit er numerisch sortiert (anderfalls gilt 12 < 8 etc.) _________________ KDE |
|
Back to top |
|
|
|