findstr.exe funktioniert nur mit der Option /i zuverlässig

findstr.exe funktioniert nur mit der Option /i zuverlässig

Postby hbuhrmester » 20.02.2015, 15:55

findstr.exe funktioniert nur zuverlässig, wenn überall die Option /i hinzugefügt wird.

Ich habe in letzter Zeit untersucht, wie sich einzelne Windows-Befehle in Linux-Kommandos übersetzen lassen. Für find.exe und sort.exe gibt es natürlich GNU find und GNU sort. findstr.exe kann man durch GNU grep ersetzen. So kann man den Aufruf:

Code: Select all
findstr.exe /B /L /G:SupersededFileIdsUnique.txt UpdateCabExeIdsAndLocations.txt > SupersededCabExeIdsAndLocations.txt


unter Linux übersetzen in:

Code: Select all
grep -F -f SupersededFileIdsUnique.txt UpdateCabExeIdsAndLocations.txt > SupersededCabExeIdsAndLocations.txt


Doch gerade bei diesem Schritt gibt es unterschiedliche Ergebnisse, die von mindestens drei verschiedenen Faktoren abhängen:

  1. Für findstr.exe muss das Locale richtig eingestellt sein. Wenn es gar nicht definiert ist, verweigert findstr.exe den Dienst und meldet nur: "Gebietsschema konnte nicht festgelegt werden". Das ist mir passiert, als ich das Windows-Skript wsusoffline/cmd/DownloadUpdates.cmd unter wine ausprobiert habe. Alle weiteren Versuche habe ich dann unter Windows XP durchgeführt.
  2. Bei findstr.exe hängt das Ergebnis von der Sortierung der beiden Ausgangsdateien ab. Je nach Sortierung findet findstr.exe mal 14989, 14906, 14170, 14236, 14203 oder 14256 Zeilen. grep findet immer genau 15384 Zeilen. Dafür gibt es eigentlich keine Erklärung: weder findstr.exe noch grep erfordern, dass die Ausgangsdateien in einer bestimmten Reihenfolge sortiert sein müssen.
  3. findstr.exe findet reproduzierbar 15384 Treffer, also dieselbe Zahl wie grep unter Linux, wenn die Option /i für einen case-insensitiven Vergleich hinzugefügt wird. Auch dafür gibt es keine Erklärung: Die Datei-Id, nach der verglichen wird, wird in allen Dateien genau gleich geschrieben; es gibt also keine Unterschiede in der Groß- und Kleinschreibung.


Untersucht habe ich diese Faktoren in einer eigenen Testsuite:

Zunächst habe ich mit einem Linuxskript 40 verschieden sortierte Varianten der beiden Ausgangsdateien hergestellt, eingeteilt in vier Gruppen:

Code: Select all
#!/bin/bash

# Die Ausgangsdateien SupersededFileIdsUnique.txt und
# UpdateCabExeIdsAndLocations.txt werden 40x zufällig gemischt.

for test in a b c d; do
    for ((i=1 ; i<=10 ; i++)); do
        echo $test $i
        sort --random-sort SupersededFileIdsUnique.txt > SupersededFileIdsUnique_${test}_${i}.txt
        sort --random-sort UpdateCabExeIdsAndLocations.txt > UpdateCabExeIdsAndLocations_${test}_${i}.txt
    done
done


Dann habe ich unter vier verschiedenen Bedingungen das Erstellen der Datei SupersededCabExeIdsAndLocations.txt getestet:

  1. Standard-Locale, case-sensitive
  2. Standard-Locale, case-insensitive
  3. Locale = C, case-sensitive
  4. Locale = C, case-insensitive

Zum Vergleich der Ergebnisse habe ich jeweils die Anzahl der Zeilen gezählt, und nach dem Sortieren der Datei SupersededCabExeIdsAndLocations.txt die md5-Prüfsummen berechnet.


Code: Select all
#!/bin/bash

# Die Ausgangsdateien SupersededFileIdsUnique_x_y.txt
# und UpdateCabExeIdsAndLocations_x_y.txt werden mit grep zu
# SupersededCabExeIdsAndLocations_x_y.txt kombiniert. Zum Vergleich
# wird die Anzahl der Zeilen gezählt und - nach einer Sortierung der
# Dateien - die md5-Prüfsumme erstellt.

echo Sortierung und Vergleich mit vorgegebenem Locale
echo Vergleich mit grep, case-sensitive

for ((i=1 ; i<=10 ; i++)); do
    grep -F -f SupersededFileIdsUnique_a_${i}.txt \
    UpdateCabExeIdsAndLocations_a_${i}.txt \
    > SupersededCabExeIdsAndLocations_a_${i}.txt

    sort SupersededCabExeIdsAndLocations_a_${i}.txt \
    > SupersededCabExeIdsAndLocationsSorted_a_${i}.txt
done

wc --lines SupersededCabExeIdsAndLocations_a_*.txt
md5sum SupersededCabExeIdsAndLocationsSorted_a_*.txt


echo Vergleich mit grep, case-insensitive

for ((i=1 ; i<=10 ; i++)); do
    grep -i -F -f SupersededFileIdsUnique_b_${i}.txt \
    UpdateCabExeIdsAndLocations_b_${i}.txt \
    > SupersededCabExeIdsAndLocations_b_${i}.txt

    sort SupersededCabExeIdsAndLocations_b_${i}.txt \
    > SupersededCabExeIdsAndLocationsSorted_b_${i}.txt
done

wc --lines SupersededCabExeIdsAndLocations_b_*.txt
md5sum SupersededCabExeIdsAndLocationsSorted_b_*.txt


echo Sortierung und Vergleich auf LC_ALL=C einstellen
export LC_ALL=C

echo Vergleich mit grep, case-sensitive

for ((i=1 ; i<=10 ; i++)); do
    grep -F -f SupersededFileIdsUnique_c_${i}.txt \
    UpdateCabExeIdsAndLocations_c_${i}.txt \
    > SupersededCabExeIdsAndLocations_c_${i}.txt

    sort SupersededCabExeIdsAndLocations_c_${i}.txt \
    > SupersededCabExeIdsAndLocationsSorted_c_${i}.txt
done

wc --lines SupersededCabExeIdsAndLocations_c_*.txt
md5sum SupersededCabExeIdsAndLocationsSorted_c_*.txt


echo Vergleich mit grep, case-insensitive

for ((i=1 ; i<=10 ; i++)); do
    grep -i -F -f SupersededFileIdsUnique_d_${i}.txt \
    UpdateCabExeIdsAndLocations_d_${i}.txt \
    > SupersededCabExeIdsAndLocations_d_${i}.txt

    sort SupersededCabExeIdsAndLocations_d_${i}.txt \
    > SupersededCabExeIdsAndLocationsSorted_d_${i}.txt
done

wc --lines SupersededCabExeIdsAndLocations_d_*.txt
md5sum SupersededCabExeIdsAndLocationsSorted_d_*.txt



Das Ergebnis sah dann so aus:

Code: Select all
Sortierung und Vergleich mit vorgegebenem Locale
Vergleich mit grep, case-sensitive
   15384 SupersededCabExeIdsAndLocations_a_10.txt
   15384 SupersededCabExeIdsAndLocations_a_1.txt
   15384 SupersededCabExeIdsAndLocations_a_2.txt
   15384 SupersededCabExeIdsAndLocations_a_3.txt
   15384 SupersededCabExeIdsAndLocations_a_4.txt
   15384 SupersededCabExeIdsAndLocations_a_5.txt
   15384 SupersededCabExeIdsAndLocations_a_6.txt
   15384 SupersededCabExeIdsAndLocations_a_7.txt
   15384 SupersededCabExeIdsAndLocations_a_8.txt
   15384 SupersededCabExeIdsAndLocations_a_9.txt
  153840 insgesamt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_10.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_1.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_2.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_3.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_4.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_5.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_6.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_7.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_8.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_a_9.txt
Vergleich mit grep, case-insensitive
   15384 SupersededCabExeIdsAndLocations_b_10.txt
   15384 SupersededCabExeIdsAndLocations_b_1.txt
   15384 SupersededCabExeIdsAndLocations_b_2.txt
   15384 SupersededCabExeIdsAndLocations_b_3.txt
   15384 SupersededCabExeIdsAndLocations_b_4.txt
   15384 SupersededCabExeIdsAndLocations_b_5.txt
   15384 SupersededCabExeIdsAndLocations_b_6.txt
   15384 SupersededCabExeIdsAndLocations_b_7.txt
   15384 SupersededCabExeIdsAndLocations_b_8.txt
   15384 SupersededCabExeIdsAndLocations_b_9.txt
  153840 insgesamt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_10.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_1.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_2.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_3.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_4.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_5.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_6.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_7.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_8.txt
c7579e2410c12130535604290dd83bbb  SupersededCabExeIdsAndLocationsSorted_b_9.txt
Sortierung und Vergleich auf LC_ALL=C einstellen
Vergleich mit grep, case-sensitive
   15384 SupersededCabExeIdsAndLocations_c_1.txt
   15384 SupersededCabExeIdsAndLocations_c_10.txt
   15384 SupersededCabExeIdsAndLocations_c_2.txt
   15384 SupersededCabExeIdsAndLocations_c_3.txt
   15384 SupersededCabExeIdsAndLocations_c_4.txt
   15384 SupersededCabExeIdsAndLocations_c_5.txt
   15384 SupersededCabExeIdsAndLocations_c_6.txt
   15384 SupersededCabExeIdsAndLocations_c_7.txt
   15384 SupersededCabExeIdsAndLocations_c_8.txt
   15384 SupersededCabExeIdsAndLocations_c_9.txt
  153840 total
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_1.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_10.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_2.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_3.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_4.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_5.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_6.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_7.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_8.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_c_9.txt
Vergleich mit grep, case-insensitive
   15384 SupersededCabExeIdsAndLocations_d_1.txt
   15384 SupersededCabExeIdsAndLocations_d_10.txt
   15384 SupersededCabExeIdsAndLocations_d_2.txt
   15384 SupersededCabExeIdsAndLocations_d_3.txt
   15384 SupersededCabExeIdsAndLocations_d_4.txt
   15384 SupersededCabExeIdsAndLocations_d_5.txt
   15384 SupersededCabExeIdsAndLocations_d_6.txt
   15384 SupersededCabExeIdsAndLocations_d_7.txt
   15384 SupersededCabExeIdsAndLocations_d_8.txt
   15384 SupersededCabExeIdsAndLocations_d_9.txt
  153840 total
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_1.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_10.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_2.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_3.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_4.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_5.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_6.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_7.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_8.txt
d2be05b70123761b7636381f53921a16  SupersededCabExeIdsAndLocationsSorted_d_9.txt


Alle Dateien haben dieselbe Länge. Die ersten 20 Dateien haben (nach der Sortierung) dieselben Prüfsummen, und die letzten 20 Dateien ebenso. Das Locale beeinflusst also die Sortierung - das ist für GNU sort auch dokumentiert und muss so sein.


Unter Windows XP habe ich dieselben Tests mit findstr.exe durchgeführt. Für die Auswertung - das Zählen der Zeilen und das Berechnen der Prüfsummen - habe ich wc und md5sum aus dem GNUWin32-Projekt eingesetzt:


Code: Select all
@echo off

rem Die Ausgangsdateien SupersededFileIdsUnique_x_y.txt
rem und UpdateCabExeIdsAndLocations_x_y.txt werden mit findstr.exe zu
rem SupersededCabExeIdsAndLocations_x_y.txt kombiniert. Zum Vergleich
rem wird die Anzahl der Zeilen gezählt und - nach einer Sortierung der
rem Dateien - die Hashsumme erstellt.

echo Sortierung und Vergleich mit vorgegebenem Locale
echo Vergleich mit findstr.exe, case-sensitive

for /L %%i in (1,1,10) do (
    findstr.exe /B /L /G:SupersededFileIdsUnique_a_%%i.txt UpdateCabExeIdsAndLocations_a_%%i.txt > SupersededCabExeIdsAndLocations_a_%%i.txt
    sort.exe SupersededCabExeIdsAndLocations_a_%%i.txt /O SupersededCabExeIdsAndLocationsSorted_a_%%i.txt
)

C:\Programme\GnuWin32\bin\wc.exe --lines SupersededCabExeIdsAndLocations_a_*.txt
C:\Programme\GnuWin32\bin\md5sum.exe SupersededCabExeIdsAndLocationsSorted_a_*.txt


echo Vergleich mit findstr.exe, case-insensitive

for /L %%i in (1,1,10) do (
    findstr.exe /I /B /L /G:SupersededFileIdsUnique_b_%%i.txt UpdateCabExeIdsAndLocations_b_%%i.txt > SupersededCabExeIdsAndLocations_b_%%i.txt
    sort.exe SupersededCabExeIdsAndLocations_b_%%i.txt /O SupersededCabExeIdsAndLocationsSorted_b_%%i.txt
)

C:\Programme\GnuWin32\bin\wc.exe --lines SupersededCabExeIdsAndLocations_b_*.txt
C:\Programme\GnuWin32\bin\md5sum.exe SupersededCabExeIdsAndLocationsSorted_b_*.txt


echo Sortierung und Vergleich auf LOCALE=C einstellen
set LOCALE=C

echo Vergleich mit findstr.exe, case-sensitive

for /L %%i in (1,1,10) do (
    findstr.exe /B /L /G:SupersededFileIdsUnique_c_%%i.txt UpdateCabExeIdsAndLocations_c_%%i.txt > SupersededCabExeIdsAndLocations_c_%%i.txt
    sort.exe SupersededCabExeIdsAndLocations_c_%%i.txt /O SupersededCabExeIdsAndLocationsSorted_c_%%i.txt
)

C:\Programme\GnuWin32\bin\wc.exe --lines SupersededCabExeIdsAndLocations_c_*.txt
C:\Programme\GnuWin32\bin\md5sum.exe SupersededCabExeIdsAndLocationsSorted_c_*.txt


echo Vergleich mit findstr.exe, case-insensitive

for /L %%i in (1,1,10) do (
    findstr.exe /I /B /L /G:SupersededFileIdsUnique_d_%%i.txt UpdateCabExeIdsAndLocations_d_%%i.txt > SupersededCabExeIdsAndLocations_d_%%i.txt
    sort.exe SupersededCabExeIdsAndLocations_d_%%i.txt /O SupersededCabExeIdsAndLocationsSorted_d_%%i.txt
)

C:\Programme\GnuWin32\bin\wc.exe --lines SupersededCabExeIdsAndLocations_d_*.txt
C:\Programme\GnuWin32\bin\md5sum.exe SupersededCabExeIdsAndLocationsSorted_d_*.txt



Die Ergebnisse für Windows:

Code: Select all
Sortierung und Vergleich mit vorgegebenem Locale
Vergleich mit findstr.exe, case-sensitive
   14135 SupersededCabExeIdsAndLocations_a_1.txt
   14212 SupersededCabExeIdsAndLocations_a_10.txt
   14350 SupersededCabExeIdsAndLocations_a_2.txt
   14235 SupersededCabExeIdsAndLocations_a_3.txt
   14163 SupersededCabExeIdsAndLocations_a_4.txt
   14237 SupersededCabExeIdsAndLocations_a_5.txt
   14261 SupersededCabExeIdsAndLocations_a_6.txt
   14284 SupersededCabExeIdsAndLocations_a_7.txt
   14225 SupersededCabExeIdsAndLocations_a_8.txt
   14188 SupersededCabExeIdsAndLocations_a_9.txt
  142290 insgesamt
f03d090c3e61e4c570df25885fc0fff7 *SupersededCabExeIdsAndLocationsSorted_a_1.txt
2b169dc4a1301e8b1ca478c3a870fc28 *SupersededCabExeIdsAndLocationsSorted_a_10.txt
9eb8bbd156c0201e451b9c2781f03a1b *SupersededCabExeIdsAndLocationsSorted_a_2.txt
65d816e0c22dfc745a7a29e249046e01 *SupersededCabExeIdsAndLocationsSorted_a_3.txt
ea6df4f7c7a3c95015b20575b3553f5f *SupersededCabExeIdsAndLocationsSorted_a_4.txt
47fffb3be9422cc285b9e0b2615f67f9 *SupersededCabExeIdsAndLocationsSorted_a_5.txt
98c8cdec161f5840d1d844bed7e11a00 *SupersededCabExeIdsAndLocationsSorted_a_6.txt
02afcaae9457fae1445b7a53415d5447 *SupersededCabExeIdsAndLocationsSorted_a_7.txt
bc7d065f204e500472b7bd77fabeede5 *SupersededCabExeIdsAndLocationsSorted_a_8.txt
f5d25dbc43df110e84ce78ccd77fff8f *SupersededCabExeIdsAndLocationsSorted_a_9.txt
Vergleich mit findstr.exe, case-insensitive
   15384 SupersededCabExeIdsAndLocations_b_1.txt
   15384 SupersededCabExeIdsAndLocations_b_10.txt
   15384 SupersededCabExeIdsAndLocations_b_2.txt
   15384 SupersededCabExeIdsAndLocations_b_3.txt
   15384 SupersededCabExeIdsAndLocations_b_4.txt
   15384 SupersededCabExeIdsAndLocations_b_5.txt
   15384 SupersededCabExeIdsAndLocations_b_6.txt
   15384 SupersededCabExeIdsAndLocations_b_7.txt
   15384 SupersededCabExeIdsAndLocations_b_8.txt
   15384 SupersededCabExeIdsAndLocations_b_9.txt
  153840 insgesamt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_1.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_10.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_2.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_3.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_4.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_5.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_6.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_7.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_8.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_b_9.txt
Sortierung und Vergleich auf LOCALE=C einstellen
Vergleich mit findstr.exe, case-sensitive
   14368 SupersededCabExeIdsAndLocations_c_1.txt
   14258 SupersededCabExeIdsAndLocations_c_10.txt
   14274 SupersededCabExeIdsAndLocations_c_2.txt
   14227 SupersededCabExeIdsAndLocations_c_3.txt
   14206 SupersededCabExeIdsAndLocations_c_4.txt
   14332 SupersededCabExeIdsAndLocations_c_5.txt
   14264 SupersededCabExeIdsAndLocations_c_6.txt
   14324 SupersededCabExeIdsAndLocations_c_7.txt
   14327 SupersededCabExeIdsAndLocations_c_8.txt
   14212 SupersededCabExeIdsAndLocations_c_9.txt
  142792 insgesamt
429333ff6bab76c1d89cc2cbcac92e5f *SupersededCabExeIdsAndLocationsSorted_c_1.txt
806bc92b5e0d7bc0de0f88a20f044137 *SupersededCabExeIdsAndLocationsSorted_c_10.txt
d0a553bad06788cb0f70776d8f05c377 *SupersededCabExeIdsAndLocationsSorted_c_2.txt
1c45e9d6bd8bbeb80aca2945747967e1 *SupersededCabExeIdsAndLocationsSorted_c_3.txt
aa56c800de55ec70f55d305e0be3ef3d *SupersededCabExeIdsAndLocationsSorted_c_4.txt
2efc893ce9744810065a710bd43d089f *SupersededCabExeIdsAndLocationsSorted_c_5.txt
d0f90292374ab4bd5ee0c727d3ffb0f4 *SupersededCabExeIdsAndLocationsSorted_c_6.txt
dcba78aab327edbab429dc5be9f7eb54 *SupersededCabExeIdsAndLocationsSorted_c_7.txt
b9fd0d81f4d6c7e4e412898937c8a148 *SupersededCabExeIdsAndLocationsSorted_c_8.txt
bde16dabe03b09a35f6ebca013c35b26 *SupersededCabExeIdsAndLocationsSorted_c_9.txt
Vergleich mit findstr.exe, case-insensitive
   15384 SupersededCabExeIdsAndLocations_d_1.txt
   15384 SupersededCabExeIdsAndLocations_d_10.txt
   15384 SupersededCabExeIdsAndLocations_d_2.txt
   15384 SupersededCabExeIdsAndLocations_d_3.txt
   15384 SupersededCabExeIdsAndLocations_d_4.txt
   15384 SupersededCabExeIdsAndLocations_d_5.txt
   15384 SupersededCabExeIdsAndLocations_d_6.txt
   15384 SupersededCabExeIdsAndLocations_d_7.txt
   15384 SupersededCabExeIdsAndLocations_d_8.txt
   15384 SupersededCabExeIdsAndLocations_d_9.txt
  153840 insgesamt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_1.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_10.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_2.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_3.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_4.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_5.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_6.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_7.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_8.txt
ef646b46748095df9b6422414c10b7d8 *SupersededCabExeIdsAndLocationsSorted_d_9.txt


Mit den Optionen findstr.exe /B /L /G bekommt man jedesmal andere Ergebnisse. Mit findstr.exe /I /B /L /G bekommt man reproduzierbar 15384 Zeilen. Das Ändern der Locale auf "C" hatte anscheinend keinen Einfluss.

Viele Grüße,

Hartmut
hbuhrmester
 
Posts: 525
Joined: 11.10.2013, 20:59

Re: findstr.exe funktioniert nur mit der Option /i zuverläss

Postby WSUSUpdateAdmin » 25.02.2015, 12:49

Hallo Hartmut,

erst einmal möchte ich mich für die späte Antwort entschuldigen - ich war ein paar Tage wegen "Landunter" quasi abgemeldet.
Dann möchte ich mich ganz doll für Deine Mühe und Deine erstklassige Arbeit bedanken! :D
Ich weiß, was das für ein Aufwand gewesen sein muss und dass eigentlich ich diese Arbeit hätte machen müssen. :oops:

Es gab ja in der Vergangenheit immer wieder Beobachtungen, dass die Ergebnisse des Windows-Downloads sich von denen des Linux-Downloads unterschieden, z.B. hier.

Ich habe das, zwar mit einem leicht mulmigen Gefühl, aber immer ein bisschen "abgetan" mit dem Hinweis auf unterschiedliche Implementierungen zwischen "grep" und "findstr".

Weiterhin habe ich in der Vergangenheit auch bemerkt, dass das Ergebnis von "findstr" von der Sortierung der Ausgangsdateien abhängt, was natürlich völlig unlogisch ist und nicht sein darf!

Deswegen habe ich sowohl bei der Ermittlung der "superseded updates" als auch bei der Ermittlung der Office-Updates ziemlich hässliche "workarounds" mit "sort" programmiert, weil ich mir nicht anders zu helfen wusste.

Ich wäre nämlich nie auf die Idee gekommen, dass /I, also ein case-insensitiver Vergleich, hier zu einer Verbesserung bzw. Stabilisierung führt - ich bin im Gegenteil immer davon ausgegangen, dass ein case-sensitiver, also "Byte"-Vergleich, tendenziell stabiler ist, weil er eben nicht z.B. vom Zeichensatz oder vom Gebietsschema abhängt.

Deine Untersuchung beweist aber, dass "findstr" schlichtweg "buggy" ist.
Eigentlich müsste man das jetzt Microsoft geben...

Wie dem auch sei: Ich werde mich nun daranmachen, alle Aufrufe von "findstr" mit /I auszustatten und vielleicht auch die oben erwähnten Vorsortierungen vorsichtig herausoperieren.

Wieder was gelernt! ;)

Herzlichen Dank noch einmal und viele Grüße,
Torsten
WSUSUpdateAdmin
Administrator
 
Posts: 2245
Joined: 07.07.2009, 14:38


Return to Anregungen / Suggestions

Who is online

Users browsing this forum: No registered users and 111 guests