Last active
January 28, 2023 00:39
-
-
Save vdbsh/cb184dc92297478ba9998058b5f9f012 to your computer and use it in GitHub Desktop.
Syncing two directories by creating symlinks at destination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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