Have you ever wanted to do something like cp -r
, but doing something different for certain subpaths?
... You haven't?
Well here is how to do it anyway:
find . -false \
-o -path . \
-o -path ./log -exec ln -s /home/friendica/{} $out/{} \; -prune \
-o -path ./view/smarty3 -exec ln -s /home/friendica/{} $out/{} \; -prune \
-o -name .git -prune \
-o -type d -exec mkdir $out/{} \; \
-o -type f -exec cp --reflink=auto {} $out/{} \;
that is: don't do anything with
.
, with ./log
or ./view/smarty3
populate them with a symlink and then don't descend any further into them, ignore any .git
directory anywhere, and with any other path, copy it normally. (The -false
is just so I can start every line with -o
.)(This example in particular could be ~mostly replicated with rsync --exclude
and putting in the symlinks afterwards, but minor modifications would make that not work anymore; also, it's possible to combine the two symlink branches in this case, but it's ugly.)
Ben Weinstein-Raun likes this.