use vars for all paths
This commit is contained in:
parent
3f73d4b9c8
commit
022ad36b6e
34
calc_md5.sh
34
calc_md5.sh
@ -1,12 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd /mnt/export
|
folder="/mnt/export/transport"
|
||||||
|
md5="md5.txt"
|
||||||
|
|
||||||
|
## prepare
|
||||||
|
cat "${md5}" > "${md5}.bak"
|
||||||
md5_tmp=`mktemp`
|
md5_tmp=`mktemp`
|
||||||
|
md5_add="${md5}.add"
|
||||||
|
|
||||||
#sort & del dublicates
|
#sort & del dublicates
|
||||||
sed -i '/^$/d' md5.txt
|
sed -i '/^$/d' "$md5"
|
||||||
cat md5.txt | sort -k 2 | uniq > $md5_tmp
|
cat "$md5" | sort -k 2 | uniq > "$md5_tmp"
|
||||||
cat $md5_tmp > md5.txt
|
cat "$md5_tmp" > "$md5"
|
||||||
|
|
||||||
cat $md5_tmp | while read line; do
|
cat $md5_tmp | while read line; do
|
||||||
#get md5
|
#get md5
|
||||||
@ -21,25 +26,28 @@ cat $md5_tmp | while read line; do
|
|||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
else
|
else
|
||||||
echo "rm $line"
|
echo "rm $line"
|
||||||
sed -i "/$md5/d" md5.txt
|
sed -i "/$md5/d" "$md5"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#search for new files
|
#search for new files
|
||||||
find /mnt/export/transport -type f | grep -v "/.Trash-" | sort | while read line; do
|
find "$folder" -type f | grep -v "/.Trash-" | sort | while read line; do
|
||||||
#save fiel path
|
#save fiel path
|
||||||
result=$(grep "$line" md5.txt); [ -z "$result" ] && {
|
result=$(grep "$line" "$md5"); [ -z "$result" ] && {
|
||||||
#wenn kein eintrag in liste...
|
#wenn kein eintrag in liste...
|
||||||
echo "new $line"
|
echo "new $line"
|
||||||
md5sum "$line" >> md5.txt_add
|
md5sum "$line" >> "$md5_add"
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
[ -f md5.txt_add ] && {
|
[ -f "$md5_add" ] && {
|
||||||
cat md5.txt_add >> md5.txt
|
cat "$md5_add" >> "$md5"
|
||||||
rm md5.txt_add
|
rm "$md5_add"
|
||||||
}
|
}
|
||||||
|
|
||||||
#sort & del dublicates
|
#sort & del dublicates
|
||||||
cat md5.txt | sort -k 2 | uniq > $md5_tmp
|
cat "$md5" | sort -k 2 | uniq > $md5_tmp
|
||||||
rm md5.txt && mv $md5_tmp md5.txt
|
rm "$md5" && mv $md5_tmp "$md5"
|
||||||
|
|
||||||
|
## diff
|
||||||
|
diff "${md5}" "${md5}.bak"
|
||||||
|
Loading…
Reference in New Issue
Block a user