wok-current annotate xcursor-human/stuff/symdup.sh @ rev 24569
sokojs: add shrink.sh (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Feb 26 18:46:53 2022 +0000 (2022-02-26) |
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 |