Have the following bash codes to deal with filenames passed randomly with mapfile. I want to call rsync on each file and send to a destination path dpath.
mapfile -d '' fl < <(
find "$dpath" -maxdepth 1 -type f "${inclnm[@]}" |
shuf -z -n "$nf"
)
Or with shuf working on arguments directly
mapfile -d '' fl < <( shuf -z -n "$nf" -e "${inclnm[@]}" )
How can I modify the two alternatives to run rsync on each file and send to destination?
As said in comments, you don't need to
mapfilean intermediate array. Just stream the null delimited selection of files torsynclike this:If you want to collect the random selection of files and use it with
rsyncthen do: