#!/bin/bash cd /mnt/export #sort & del dublicates sed -i '/^$/d' md5.txt cat md5.txt | sort -k 2 | uniq > md5.txt_tmp cat md5.txt_tmp > md5.txt cat md5.txt_tmp | while read line; do #get md5 md5=$(echo $line | cut -c -32) #get path of file file=$( echo $line | cut -c 34-) #wenn datei existiert if [ -f "$file" ]; then # do nothing echo > /dev/null else echo "rm $line" sed -i "/$md5/d" md5.txt fi done #search for new files find /mnt/export/transport -type f | grep -v "/.Trash-" | sort | while read line; do #save fiel path result=$(grep "$line" md5.txt); [ -z "$result" ] && { #wenn kein eintrag in liste... echo "new $line" md5sum "$line" >> md5.txt_add } done [ -f md5.txt_add ] && { cat md5.txt_add >> md5.txt rm md5.txt_add } #sort & del dublicates cat md5.txt | sort -k 2 | uniq > md5.txt_tmp rm md5.txt && mv md5.txt_tmp md5.txt