wok annotate xcursor-obsidian/stuff/symdup.sh @ rev 24031

updated dialog (1.3_20190211 -> 1.3_20210324)
author Hans-G?nter Theisgen
date Tue Apr 06 13:52:57 2021 +0100 (2021-04-06)
parents
children
rev   line source
al@18055 1 # substitute repeated files by symlinks
al@18055 2 md5file=$(mktemp)
al@18055 3 find $install -type f -exec md5sum {} \; | sort > $md5file
al@18055 4
al@18055 5 for md in $(uniq -d -w32 $md5file | cut -c1-32); do
al@18055 6 # group of similar files
al@18055 7 similar="$(grep $md $md5file | cut -c35-)"
al@18055 8
al@18055 9 # find shortest filename
al@18055 10 shortest=$(echo "$similar" | cut -d' ' -f1)
al@18055 11 for line in $(echo $similar); do
al@18055 12 [ "${#line}" -lt "${#shortest}" ] && shortest="$line"
al@18055 13 done
al@18055 14
al@18055 15 # make symlinks to the file with shortest filename
al@18055 16 for file in $similar; do
al@18055 17 [ "$shortest" != "$file" ] && ln -sf $shortest $file
al@18055 18 done
al@18055 19 done
al@18055 20 rm "$md5file"
al@18055 21
al@18055 22 # make all symlinks relative
al@18055 23 symlinks -crs $install