You can pipe Linux find command output to mv command to move files or directories with certain name or extension.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
## By extension mkdir mydir{1,2} touch mydir1/myfile.{sh,txt,zip,tar} find mydir1/ -type f -name "*.t*" | xargs mv -t mydir2 ls mydir2 ## returns myfile.tar myfile.tx rm -r my* ## By name mkdir mydir{1,2} touch mydir1/{aws,azure_devops,gcp,azure}_conf.txt find mydir1/ -type f -name "azure*" | xargs mv -t mydir2 ls mydir2 ## returns azure_conf.txt azure_devops_conf.txt rm -r my* |