md5_cp/select
2019-09-13 12:31:57 +02:00

38 lines
993 B
Bash
Executable File

#!/bin/bash
md5_source="2cp.md5"
md5_source_rm="2rm.md5"
md5_aim="aim.md5"
#wenn delete file exits -> handle deletons (importand for konflict handling
[ -f "${md5_source_rm}" ] && {
cat "${md5_source_rm}" | cut -c -32 | while read line; do
sed -i "/$line/d" "${md5_aim}"
done
cat "${md5_source_rm}" | cut -c 35- | while read line; do
l=$(grep " $line"$ "${md5_aim}")
[ -n "$l" ] && {
echo $l
md5=$(echo $l | cut -c -32)
sed -i "/$md5/d" "${md5_aim}"
}
done
rm ${md5_source_rm}
}
#gleiche dateien anhand md5 aussortieren
cat "${md5_aim}" | cut -c -32 | while read line; do sed -i "/$line/d" "${md5_source}" ; done
#dateien die verschiedenen md5 haben aber bei beiden existieren als konflikte behandeln
echo Konflicts:
echo
cat "${md5_aim}" | cut -c 35- | while read line; do
l=$(grep " $line"$ "${md5_source}" | tee -a konflicts)
[ -n "$l" ] && {
echo $l
md5=$(echo $l | cut -c -32)
sed -i "/$md5/d" "${md5_source}"
}
done