Find files on linux and move them to a temporary directory
These are the commands to search and move data on linux
-iname – File name search pattern (case insensitive)
Move .mp3 files and not directories, use:
find / -iname "*.mp3" -type f -exec /bin/mv {} /mnt/mp3 \;
Find all directories having name mp3 and move:
# find / -iname "*.mp3" -type d -exec /bin/mv {} /mnt/mp3 \;
Above commands will not maintain sub-directory structure. Try replacing mv with rsync to use the same directory structure on the target directory.
You need to pass the –remove-source-files option to the rsync command to delete source file.
find /var/www/DIRECTORY_TO_FIND_DATA -iname "*FIND_MATCHING_STRING*" -type f -print0 | xargs -0 -I '{}' /usr/bin/rsync --remove-source-files -avR "{}" /DIRECTORY_TO_MOVED_IN