Last update: 2024-08-26
Explanation:1
rsync -av:
-a (archive mode) preserves file attributes like timestamps, permissions, and symbolic links.
-v (verbose) gives detailed output during the operation.
--include="*/": Ensures that all directories are included in the synchronization.
--include="*.md": Includes only .md files in the synchronization.
--exclude="*": Excludes everything else, so only .md files and directories are considered.
"${SOURCE_DIR}" and "${DEST_DIR}" represent the source and destination directories, respectively. Ensure that these paths end with a slash (/) to avoid any path concatenation issues.
#!/bin/bash
# Source directory containing the markdown files
SOURCE_DIR="/path/to/source/directory/"
# Destination directory where files will be synchronized
DEST_DIR="/path/to/destination/directory/"
# Perform the synchronization with rsync
rsync -av --include="*/" --include="*.md" --exclude="*" "$SOURCE_DIR" "$DEST_DIR"
echo "Synchronized .md files from $SOURCE_DIR to $DEST_DIR."
Based on code via ChatGPT↩︎