Linux – How to recursively copy all pdf files in a directory (and it’s subdirectories) into a single output directory

command linelinux

I have a directory containing a large number of PDF files, some of which are in subdirectories (which can extend several layers deep). I would like to move all files matching *.pdf into a single output folder named papers.

How can I do this?

Best Answer

If you use bash in a recent version, you can profit from the globstar option:

shopt -s globstar
mv **/*.pdf papers/
Related Question