Solved. Had to create an array and use “$i” as the source in the rsync arguments.
I would like to create a script that uses a heredoc as input to Rsync’s “–files-from” option but I cannot seem to get it figured out. Per the man page…
--files-from=FILE
Using this option allows you to specify the exact list of files to transfer (as read from the specified FILE or - for
standard input).
It also tweaks the default behavior of rsync to make transferring just the specified files and directories easier:
A snippet of my script as follows:
# Getting include list
declare -a theList=(
"$HOME/Documents/MyDocs"
"$HOME/Downloads"
"$HOME"/Library/Preferences/com.apple.dock.plist
"$HOME"/Library/Preferences/com.apple.finder.plist
"$HOME"/Library/Preferences/com.apple.menuextra.battery.plist
"$HOME"/Library/Preferences/com.apple.menuextra.clock.plist
"$HOME"/Library/Preferences/com.apple.sidebarlists.plist
)
/usr/bin/rsync -avzEh --files-from=${theList[@]} --exclude=".DS_Store" "$theDestination"/host-desktop
I’ve also tried:
# Include list
theList(){
"$HOME/Documents/MyDocs"
"$HOME/Downloads"
"$HOME"/Library/Preferences/com.apple.dock.plist
"$HOME"/Library/Preferences/com.apple.finder.plist
"$HOME"/Library/Preferences/com.apple.menuextra.battery.plist
"$HOME"/Library/Preferences/com.apple.menuextra.clock.plist
"$HOME"/Library/Preferences/com.apple.sidebarlists.plist
)
As well as:
/usr/bin/rsync -avzEh /Users/me/Test --exclude=".DS_Store" --files-from=- <<-"EOF"
- "$HOME/Documents/MyDocs"
- "$HOME/Downloads"
- "$HOME"/Library/Preferences/com.apple.dock.plist
- "$HOME"/Library/Preferences/com.apple.finder.plist
- "$HOME"/Library/Preferences/com.apple.menuextra.battery.plist
- "$HOME"/Library/Preferences/com.apple.menuextra.clock.plist
- "$HOME"/Library/Preferences/com.apple.sidebarlists.plist
EOF
In an attempt to follow what I saw here.