To illustrate the original file: Moving target: Step: 1. Find the file that meets the criteria and create the target directory find/root/-maxdepth 5-name ' *.log '-exec echo {} \;|sed "s/
\/root\//
\/root\/mv2\//g "|sed" s/[^/]*\.log//"|awk ' {System (" Mkdir-p "$")} ' 2. Find the file that meets the criteria and move the file to the destination directory find/root/-maxdepth 5-name ' *.log '- exec echo {} {} \; |sed "s/
\/root\//
\/root\/mv2\//g "|awk ' {System (" MV "$" $)} ' command description: The feature moves all the. log files under the root directory to the MV2 subdirectory. A. Always use absolute path when searching, otherwise the MV and mkdir commands will go wrong B. 2nd step: sed replaces character with spaces
Linux commands: Bulk move or copy the found files to another directory and keep the original file directory structure as much as possible