You can use cp -t or –target-directory=DIRECTORY to copy all SOURCE arguments into DIRECTORY.
1 2 3 4 5 6 7 8 |
mkdir mydir{1,2} ## create some files and directories touch mydir1/myfile.{sh,txt,zip,tar} find mydir1/ -type f -name "*.t*" | xargs cp mydir2 ## does not works ## cp: target ‘mydir1/myfile.tar’ is not a directory find mydir1/ -type f -name "*.t*" | xargs cp -t mydir2 ## works with -t option rm -r my* |