I have a task to copy all files from multiple directories with special names to a target directory.
So I build this directory to test my command. The test directory tree looks like:
.
├── dir1
│ └── file1
└── test
My intended command to mv all files from dir1 to test is:
find . -type d -name "*dir*" -exec mv {}/* test \;
Then I got:
mv: rename ./dir1/* to test/*: No such file or directory
I guess this is because in that extra -exec expression, the command didn't treat the * as a wildcard.
So I did:
find . -type d -name "*dir*" -exec mv {}/file1 test \;
Which successfully moved file1 to test.
But the point is, I need to now the expression for all files so that I can accomplish this file transfer work.
How should I express that in the find -exec
command group?