I have a large directory full of various shapefiles. I'd like to move or copy all of the files ending in _31. or _32. to a different directory (mac osx).
## Find all shapefiles ending in 31
find ./ -iname '*_31.*' 2>/dev/null
## Find all shapefiles ending in 32
find ./ -iname '*_32.*' 2>/dev/null
The above find calls successfully find all of the desired files. Now I'd like to move or copy those results to the new directory. Any ideas?
This is a job for xargs!
find ./ -iname '*_32.*' | xargs -I _ cp _ destination
xargs will take the output of find and run a command on each line.
-I _
sets a place holder for the incoming line that is then used in the cp command.