Skip to main content
added 811 characters in body
Source Link
Zeta
  • 1.1k
  • 6
  • 11

Use find's -print0 in combination with rsync --files-from=- -0:

find "${Share}" <predicates>-depth -mindepth 1 \( \
-type f \! -exec fuser -s '{}' \; -o \
-type d \! -empty \) -print0 | rsync --files-from=- -0 "${Share}" ${POOL}

Now find will generate a list of found files separated by \0 (due to -print0 will delimit). NUL isn't a valid character for a file name, so it's safe to use as a delimiter in a list. That list is printed to the entriesstandard output and read by \0rsync. --files-from=-rsync will takeusually gets the source files that should get transferred from standard input instead fromas arguments., but can read a file instead:

find $PATH [your conditions here] -print > my-file-list.txt
rsync --files-from=my-file-list.txt $PATH $DESTINATION

Of course, since we used -0print0 (orand not --from0print) tells, we need to tell rsync that thosethe files are delimited by \0.:

find $PATH [your conditions here] -print0 > my-file-list.txt
rsync --files-from=my-file-list.txt -0 $PATH $DESTINATION

We can use - as argument for --files-from to tell rsync that the files should be read from its standard input and get rid of the intermediate file:

find $PATH [your conditions here] -print0 \
  | rsync --files-from=- -0 $PATH $DESTINATION

Note that rsync still needs a path as source, but it will only transfer the files found by find.

Use find's -print0 in combination with rsync --files-from=- -0:

find "${Share}" <predicates> -print0 | rsync --files-from=- -0 "${Share}" ${POOL}

-print0 will delimit the entries by \0. --files-from=- will take the files that should get transferred from standard input instead from arguments. -0 (or --from0) tells rsync that those files are delimited by \0. Note that rsync still needs a path as source, but it will only transfer the files found by find.

Use find's -print0 in combination with rsync --files-from=- -0:

find "${Share}" -depth -mindepth 1 \( \
-type f \! -exec fuser -s '{}' \; -o \
-type d \! -empty \) -print0 | rsync --files-from=- -0 "${Share}" ${POOL}

Now find will generate a list of found files separated by \0 (due to -print0). NUL isn't a valid character for a file name, so it's safe to use as a delimiter in a list. That list is printed to the standard output and read by rsync. rsync usually gets the source files as arguments, but can read a file instead:

find $PATH [your conditions here] -print > my-file-list.txt
rsync --files-from=my-file-list.txt $PATH $DESTINATION

Of course, since we used -print0 and not -print, we need to tell rsync that the files are delimited by \0:

find $PATH [your conditions here] -print0 > my-file-list.txt
rsync --files-from=my-file-list.txt -0 $PATH $DESTINATION

We can use - as argument for --files-from to tell rsync that the files should be read from its standard input and get rid of the intermediate file:

find $PATH [your conditions here] -print0 \
  | rsync --files-from=- -0 $PATH $DESTINATION

Note that rsync still needs a path as source, but it will only transfer the files found by find.

fix wrong argument
Source Link
Zeta
  • 1.1k
  • 6
  • 11

Use find's -print0 in combination with rsync --fromfiles-file=from=- -0:

find "${Share}" <predicates> -print0 | rsync --fromfiles-file=from=- -0 "${Share}" ${POOL}

-print0 will delimit the entries by \0. --fromfiles-file=from=- will take the files that should get transferred from standard input instead from arguments. -0 (or --from0) tells rsync that those files are delimited by \0. Note that rsync still needs a path as source, but it will only transfer the files found by find.

Use find's -print0 in combination with rsync --from-file=- -0:

find "${Share}" <predicates> -print0 | rsync --from-file=- -0 "${Share}" ${POOL}

-print0 will delimit the entries by \0. --from-file=- will take the files that should get transferred from standard input instead from arguments. -0 tells rsync that those files are delimited by \0. Note that rsync still needs a path as source, but it will only transfer the files found by find.

Use find's -print0 in combination with rsync --files-from=- -0:

find "${Share}" <predicates> -print0 | rsync --files-from=- -0 "${Share}" ${POOL}

-print0 will delimit the entries by \0. --files-from=- will take the files that should get transferred from standard input instead from arguments. -0 (or --from0) tells rsync that those files are delimited by \0. Note that rsync still needs a path as source, but it will only transfer the files found by find.

Source Link
Zeta
  • 1.1k
  • 6
  • 11

Use find's -print0 in combination with rsync --from-file=- -0:

find "${Share}" <predicates> -print0 | rsync --from-file=- -0 "${Share}" ${POOL}

-print0 will delimit the entries by \0. --from-file=- will take the files that should get transferred from standard input instead from arguments. -0 tells rsync that those files are delimited by \0. Note that rsync still needs a path as source, but it will only transfer the files found by find.