Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux - How can I copy files of the same extension located in several subdirectories into a single directly?

I have a folder which has many subdirectories, each with a *.nr file in them. There are 1000 subdirectories, each containing at least one *.nr file. Is there a quick way to copy all those *.nr files into a single directory?

I can write a quick python script to iterate through the files, but this seems like overkill if there is a quick command line based way to do it.

I've been googling, but I'm not sure what exact terms I should be googling.

Thanks!

like image 407
Brett Avatar asked Dec 12 '22 16:12

Brett


1 Answers

something like

find /path/to/src -name "*.nr" -exec cp \{\} /path/to/dest \;
like image 166
Paul Dixon Avatar answered Jan 05 '23 00:01

Paul Dixon