pkg/symbolic-merge.sh from @Fang-

This commit is contained in:
Ted Blackman 2021-08-30 20:19:16 +03:00
parent 5f4c02c6d2
commit f277c9f1ae

26
pkg/symbolic-merge.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# call from within pkg/ as ./symbolic-merge.sh source-pkg target-pkg
function link() { # source desk, target desk, filepath
local src=${3:2}; # strip leading ./
local pax=$src;
local rel=$1;
while [[ "." != $(dirname "$pax") ]]; do
pax=$(dirname "$pax");
rel="../$rel";
done;
ln -sf "../$rel/$src" "../$2/$src";
}
# mirror directory structure
cd $1;
find . -type d -exec mkdir -p ../$2/{} \;
# symlink all files, overwriting existing ones
export -f link
find . -type f \
-not -name '*.bill' \
-not -name '*.kelvin' \
-exec bash -c "link $1 $2 {}" \;