find files and copy them

Bash shell is the common linux command language.
Post Reply
mister_v
Posts: 177
Joined: Thu Mar 04, 2010 9:19 pm

find files and copy them

Post by mister_v »

hi

I would like to use the result of a find command into a copy command
find -iname *.xlsx
and then cp * to dir/


does anyone know how to do this?
chris
Site Admin
Posts: 180
Joined: Mon Jul 21, 2008 9:52 am

Re: find files and copy them

Post by chris »

The easiest way (and because it also copies files with spaces in the name) is:

Code: Select all

find -iname *.xlsx -exec cp '{}' dir/ \;
It is an option of find,
for more info check man find
Post Reply