0

I have a lot of directories that contain some text files and I would copy all files (of all directories) in a new directory. I'm looking for a bash command that do this. How can I do it?

linofex
  • 554
  • 1
  • 9
  • 28

2 Answers2

0

Try

find source_dir '*.txt' -exec cp -vuni '{}' dest_dir ";"
0

You can use the this command to copy all the files and subfolders in a directory to another directory:

cp -a /source/. /dest/

Taken from How can I copy the contents of a folder to another folder in a different directory using terminal?

Note: This does not solve OP's question as you cannot use it to only copy files of a certain type along with folders, but I'll leave it here for anyone that might need it.

carreter
  • 138