Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
sort kaputt?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 3369
Location: de

PostPosted: Thu Jan 07, 2010 2:57 pm    Post subject: sort kaputt? Reply with quote

Hallo,

ich beschreib mal kurz die Situation:
Ich hab 2 Verzeichnisse mit Unterverzeichnissen. Die wollte ich jetzt vergleichen. Dazu saß ich gestern an einem Cygwin, wo es anscheinend funktionierte. Und heut beim Ubuntu krieg ich die Krise, weil dieselbe Prozedur anscheinen nicht mehr klappt.

1. Verzeichnislisten einlesen und sortieren.
Code:
cd verzeichnis1
find features/ plugins/ > blubb.txt
sort blubb.txt > blubb_sorted.txt
cd verzeichnis 2
find features/ plugins/ > blah.txt
sort blah.txt > blah_sorted.txt

Soweit so gut. Hier liegen jetzt beide Dateien mit korrekt sortiertem Inhalt vor.

2. Dateien vergleichen und sortieren
Code:
diff blubb_sorted.txt blah_sorted.txt > b1.txt
sort b1.txt > b11.txt

Und jetzt tritt das Problem auf. b11.txt ist zwar sortiert, allerdings nach den Verzeichnisnamen. Die Zeichen für die Unterschiede (<,>) am Anfang der Zeile werden aus unerfindlichen Gründen ignoriert. Beispiel:
< verzeichnis/datei1
< verzeichnis/datei2
> verzeichnis/datei3
< verzeichnis/datei4

Ist das jetzt 'n Bug von sort, oder hab ich da irgendeine Option übersehen? Mit -n kann man numerisch sortieren lassen, was aber am geschilderten Problem nichts ändert.

Anmerkung:
diff scheint irgendwie auch nicht mehr zu funktionieren. Zumindest hab ich hier grad sowas auf dem Bildschirm
Code:
> plugins/org.eclipse.ui.intro.universal_3.2.300.v20090526/themes/slate/graphics/rootpage/migrate48.gif
1333d1440
< plugins/org.eclipse.ui.intro.universal_3.2.300.v20090526/themes/slate/graphics/rootpage/migrate48.gif
1334a1442
Back to top
View user's profile Send private message
Knieper
l33t
l33t


Joined: 10 Nov 2005
Posts: 846

PostPosted: Thu Jan 07, 2010 3:54 pm    Post subject: Reply with quote

Hast Du ein alias, das "-d" hinzufügt?

Edit: dann müsste aber zB. bei -n "incompatible options" kommen...
_________________
Je dümmer desto Gnome/KDE.
Back to top
View user's profile Send private message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 3369
Location: de

PostPosted: Fri Jan 08, 2010 8:03 pm    Post subject: Reply with quote

Knieper wrote:
Hast Du ein alias, das "-d" hinzufügt?

Nein, war eine frische Ubuntu-Installation. Ich schieb's mal auf das Ubuntu.
Back to top
View user's profile Send private message
slick
Bodhisattva
Bodhisattva


Joined: 20 Apr 2003
Posts: 3495

PostPosted: Mon Jan 11, 2010 7:57 am    Post subject: Reply with quote

musv wrote:
Und heut beim Ubuntu krieg ich die Krise, weil dieselbe Prozedur anscheinen nicht mehr klappt.

musv wrote:
Nein, war eine frische Ubuntu-Installation. Ich schieb's mal auf das Ubuntu.


8O Oh .. sind wir jetzt ein Ubuntu-Forum?

(Konnt ich mir jetzt nicht verkneifen)
Back to top
View user's profile Send private message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 3369
Location: de

PostPosted: Wed Jan 13, 2010 9:43 pm    Post subject: Reply with quote

slick wrote:
8O Oh .. sind wir jetzt ein Ubuntu-Forum?

Ein bisschen schon. Deswegen hab ich's hier ja gepostet. :P
Back to top
View user's profile Send private message
Yamakuzure
Advocate
Advocate


Joined: 21 Jun 2006
Posts: 2305
Location: Adendorf, Germany

PostPosted: Thu Jan 14, 2010 10:19 am    Post subject: Reply with quote

Ich versuch das mal nachzuvollziehen. Zeilen, die mit ## anfangen, habe ich reineditiert:
Code:
sed@sed-notebook ~$ mkdir -p /tmp/test ; cd /tmp/test
sed@sed-notebook ~/tmp/test $ mkdir blah ; mkdir blubb
sed@sed-notebook ~/tmp/test $ for nr in 1 2 3 4 5 6 7 8 9 ; do touch blah/test${nr}.txt ; touch blubb/test${nr}.txt ; done

## Jetzt sind zwei Verzeichnisse da mit gleichen Dateien

sed@sed-notebook ~/tmp/test $ for nr in 12 13 14 ; do for alpha in a b c ; do touch blah/neu_${alpha}_${nr}.txt ; done ; done
sed@sed-notebook ~/tmp/test $ for nr in 17 23 44 ; do for alpha in x y z ; do touch blubb/neu_${alpha}_${nr}.txt ; done ; done
sed@sed-notebook ~/tmp/test $ ls */
blah/:
neu_a_12.txt  neu_a_14.txt  neu_b_13.txt  neu_c_12.txt  neu_c_14.txt  test2.txt  test4.txt  test6.txt  test8.txt
neu_a_13.txt  neu_b_12.txt  neu_b_14.txt  neu_c_13.txt  test1.txt     test3.txt  test5.txt  test7.txt  test9.txt

blubb/:
neu_x_17.txt  neu_x_44.txt  neu_y_23.txt  neu_z_17.txt  neu_z_44.txt  test2.txt  test4.txt  test6.txt  test8.txt
neu_x_23.txt  neu_y_17.txt  neu_y_44.txt  neu_z_23.txt  test1.txt     test3.txt  test5.txt  test7.txt  test9.txt

## Jetzt haben wir noch ein paar unterschiedliche Dateien dazu. (Sonst wirft diff ja nix aus.)

sed@sed-notebook ~/tmp/test $ cd blah
sed@sed-notebook ~/tmp/test/blah $ find > ../blah.txt
sed@sed-notebook ~/tmp/test/blah $ cd ../blubb
sed@sed-notebook ~/tmp/test/blubb $ find > ../blubb.txt
sed@sed-notebook ~/tmp/test/blubb $ cd ..
sed@sed-notebook ~/tmp/test $ sort blah.txt > blah_sorted.txt
sed@sed-notebook ~/tmp/test $ sort blubb.txt > blubb_sorted.txt

## Jetzt haben wir die listen wie von dir beschrieben und sortiert.

sed@sed-notebook ~/tmp/test $ cat *_sorted.txt
.
./neu_a_12.txt
./neu_a_13.txt
./neu_a_14.txt
./neu_b_12.txt
./neu_b_13.txt
./neu_b_14.txt
./neu_c_12.txt
./neu_c_13.txt
./neu_c_14.txt
./test1.txt
./test2.txt
./test3.txt
./test4.txt
./test5.txt
./test6.txt
./test7.txt
./test8.txt
./test9.txt
.
./neu_x_17.txt
./neu_x_23.txt
./neu_x_44.txt
./neu_y_17.txt
./neu_y_23.txt
./neu_y_44.txt
./neu_z_17.txt
./neu_z_23.txt
./neu_z_44.txt
./test1.txt
./test2.txt
./test3.txt
./test4.txt
./test5.txt
./test6.txt
./test7.txt
./test8.txt
./test9.txt

## Die Listen sind vollständig, korrekt sortiert und definitiv unterschiedlich.

sed@sed-notebook ~/tmp/test $ diff blubb_sorted.txt blah_sorted.txt > b1.txt
sed@sed-notebook ~/tmp/test $ sort b1.txt > b11.txt
sed@sed-notebook ~/tmp/test $ cat b11.txt
---
2,10c2,10
< ./neu_x_17.txt
< ./neu_x_23.txt
< ./neu_x_44.txt
< ./neu_y_17.txt
< ./neu_y_23.txt
< ./neu_y_44.txt
< ./neu_z_17.txt
< ./neu_z_23.txt
< ./neu_z_44.txt
> ./neu_a_12.txt
> ./neu_a_13.txt
> ./neu_a_14.txt
> ./neu_b_12.txt
> ./neu_b_13.txt
> ./neu_b_14.txt
> ./neu_c_12.txt
> ./neu_c_13.txt
> ./neu_c_14.txt
Funktioniert einwandfrei unter Gentoo. Ich verweise also mal ganz vorsichtig aber fröhlich auf http://forum.ubuntuusers.de/ ... ;)
_________________
Edited 220,176 times by Yamakuzure
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum