If you are using Bash, you can convert stdout to an array of lines by mapfile
:
find . | grep "FooBar" | (mapfile -t; cp "${MAPFILE[@]}" ~/foobar)
The benefits are:
You can append other arguments to the file names. For cp
, you can also:
find . -name '*FooBar*' -exec cp -t ~/foobar -- {} +
however, some commands don't have such feature.
The disadvantages:
Well... who knows if Bash is available on OS X?