I want to be able to search for files over 14 days and over 10k and than rsync those found files to a destination.
Is there a way to combine these two commands?
find ./ -mtime +14 -size +10k
rsync --remove-sent-files -avz /src /dest
bashfindpipersyncshell
I want to be able to search for files over 14 days and over 10k and than rsync those found files to a destination.
Is there a way to combine these two commands?
find ./ -mtime +14 -size +10k
rsync --remove-sent-files -avz /src /dest
Best Answer
You can send the output of find into rsync using one of the options outlined below.
Method #1
These 2 options are very similar, they both assume you're changing directories to some location and then running the
find
command from there.You can also use a pipe to feed the list in:
Method #2
This method can be run from anywhere.
printf %P
: File's name with the name of the command line argument under which it was found removed. This way, you can use any src directory, no need to cd into your src directory first.References