Code to find files of a certain type and copy

You can use the following code to find files of a certain type, on Linux, and copy all of them to a new location. In the example below all “.tar” files are copied to /newfolder:

find /root -iname "*.tar" -execdir cp '{}' /newfolder/ \;

Updated

Slightly different syntax which, as I recall, works on newer versions of Linux:

find /usr/share -name '*.png' -exec cp  {} /home/guy/PNG \;

Leave a Reply