## Mittwoch, 7. Dezember 2011

### Copy files recursively without keeping directory structure (Linux)

We had to copy many files that were located in a very complex directory structure. The following snippet searches the current directory and its subdirectories for *.xml files & executes the cp command on every file it finds (the braces {} represent the file):

find -type f -iname '*.xml' -exec cp {} /target/dir/for/all/xmls/ \;

The target dir now contains all *.xml files without directories.

#### 3 Kommentare:

1. The correct command is : find -type f -iname '*.xml' -exec cp {} /target/dir/for/all/xmls/ \;
No "-" before the "f" of the parameter type.

2. Hi igl,

thank you very much for pointing that out. I corrected it in the example.

Kind regards
Marc

3. I'm all new to linux and it helps me learn these commands when I know the
"full anatomy" of it, so to speak.

I can see what each bit of it represents, except the last "\;", what does it mean?