This answer does not take the "not older than 1 day" restriction into account.
Rather than trying to parse the output of find
, use rsync
directly from find
:
find /mnt/IP/ftp/123 -type -name '1[14].*' -prune \
-exec rsync -av \
--include='*.bin' --include='*/' \
--exclude='*' --prune-empty-dirs {} /home/ftp/123 ';'
This would find the directories whose names start with either 11.
or 14.
in or under /mnt/IP/ftp/123
. For each such directory, it would remove the directory from the search list (with -prune
), and then execute
rsync -av --include='*.bin' --include='*/' \
--exclude='*' --prune-empty-dirs {} /home/ftp/123
where {}
would be replaced by the pathname of the found directory.
The rsync
command would create a subdirectory of /home/ftp/123
with the same filename as the found directory (i.e. starting with either 11.
or 14.
) and then copy the .bin
files.
The inclusion and exclusion patterns used with rsync
(first match wins):
--include='*.bin'
: include any file whose filename ends with .bin
.
--include='*/'
: include any directory. Empty directories at the target will be removed due to --prune-empty-dirs
.
--exclude='*'
: exclude anything not included by the previous rules.
find ... | grep ... | rsync -av --files-from=- /home/ftp/123
– Satō Katsura Feb 20 '17 at 17:04