wok-next view suru-icon-theme/stuff/repeats2symlinks @ rev 21540

updated cantarell-fonts (0.111 -> 0.201)
author Hans-G?nter Theisgen
date Sun Jun 21 16:26:44 2020 +0100 (2020-06-21)
parents
children
line source
1 #!/bin/sh
3 # Substitute repeated files by symlinks
5 where="$1"
7 md5sums=$(mktemp)
8 find $where -type f -exec md5sum '{}' \; | sort > $md5sums
10 # Return shortest line
11 shortest_line() {
12 shortest=$1; shift
13 for line in $@; do
14 [ "${#line}" -lt "${#shortest}" ] && shortest="$line"
15 done
16 echo "$shortest"
17 }
20 # Replace the same files by symlinks, $@ - list of identical files
21 make_symlinks() {
22 target=$(shortest_line $@)
23 for file in $@; do
24 [ "$target" != "$file" ] && ln -sf $target $file
25 done
26 }
28 # substitute repeated files by symlinks
29 for md in $(uniq -d -w32 $md5sums | cut -c1-32); do
30 make_symlinks $(grep $md $md5sums | cut -c35-)
31 done
33 # clean
34 rm $md5sums
36 # make all symlinks relative
37 symlinks -crs $where 2>/dev/null