md5sum nur neue dateien?

730
user13798

Ich habe ein Verzeichnis mit Dateien und eine md5sum.txt-Datei. Ich füge dem Verzeichnis eine neue Datei hinzu. Ich möchte md5sum-Summen für alle Dateien hinzufügen, die nicht in md5sum.txt enthalten sind.

Gibt es eine einfache Möglichkeit, dies zu tun?

3
Nach welcher Art von Skript suchst du? Welches Betriebssystem verwenden Sie? innaM vor 14 Jahren 1
you basically have to script reading in your md5sum.txt and directory listing and weed out from there. i'd probably choose perl for the task. quack quixote vor 14 Jahren 0
Ich verwende Linux. user13798 vor 14 Jahren 0

1 Antwort auf die Frage

2
Kyle-tummy.com

Sie können diese kleine Nummer ausprobieren:

#We want the seperator to be newlines, not spaces IFS="$(echo -e "\n\r")" for EACHFILE in `ls -1` do # If grep can't find the filename in that text file if ! egrep -q " $EACHFILE$" md5sum.txt; then md5sum $EACHFILE fi done 

Dies setzt voraus, dass die Textdatei so ist:

964e6b94e921b5f0879b41956b787050 Testdatei

Welches ist Standardausgabe

In OSX musste ich die zweite Zeile in: IFS = $ '\ n' ändern Josep Valls vor 8 Jahren 0