wok-6.x annotate xcursor-human/stuff/symdup.sh @ rev 22792
recompiled xneur
author | Hans-G?nter Theisgen |
---|---|
date | Mon Jan 27 09:19:20 2020 +0100 (2020-01-27) |
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 |