dont change original md5 files while select files to cp

This commit is contained in:
2019-09-13 12:36:24 +02:00
parent 0256d54ff7
commit b0e9c42a5d

22
select
View File

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