I'd like to use the find command with the -exec action with the plus (+) sign (for efficiency), or with xargs to copy files from one directory to another. The following answer did not work for me. I'm under bash version: 4.3.48(1). Trying:
find . \( \( -type f -size -2M \) -o \( -type f -size 2M \) \) -exec cp '{}' ~/Pictures/test_folder '+'
or:
find . \( -type f -size -2M \) -o \( -type f -size 2M \) | xargs cp -t ~/Pictures/test_folder
does not work for me. Maybe I've made a syntactic error of some kind, but I've already tried several variations of the above commands and I still can't get it to work. The test folder is the location where I'd like the files to be copied to.
find: missing argument to -exec
If I enter the second command, I get a message error for each file, i.e.cp: cannot stat './file1': No such file or directory
, and only one file gets copied into the test folder.