Skip to content

Instantly share code, notes, and snippets.

@vdbsh
Last active January 28, 2023 00:39
Show Gist options
  • Save vdbsh/cb184dc92297478ba9998058b5f9f012 to your computer and use it in GitHub Desktop.
Save vdbsh/cb184dc92297478ba9998058b5f9f012 to your computer and use it in GitHub Desktop.
Syncing two directories by creating symlinks at destination
#!/usr/bin/env bash
# microsync.sh: Syncing two directories by creating symlinks at destination.
source="/Users/user/source"
destination="/Users/user/destination"
# Delete broken symlinks and empty directories if any
find "$destination" -type l ! -exec test -e {} \; -exec rm {} \;
find "$destination" -type d -empty -delete
# Create symlinks recursively
cp -aR -s "$source" "$destination"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment