Today I had to copy several PDFs from various subdirectories to another folder. To find all occurrences of a certain type of file I used find and piped the result to cp.

cd /home/andreas/papers
find . -name *.pdf -exec cp {} /destination/path \;

All arguments to find are taken to be arguments to the command until an argument consisting of ';' is encountered[1]. The '\' escapes that character to protect it expansion by the shell. '{}' represents the list of files retrieved by find. So we can use find for a lot of different tasks which actually makes life quite easy ;)

 

[1] man page of find

Last Updated (Wednesday, 11 November 2009 20:11)

 

Add comment


Security code
Refresh

Sponsored links: