bash how mv */*.* /some/other/directory
I have a directory containing about 150 sub-directories, each of which contains only files of various types. I need to get all those files together in a single directory without any of the subdirectories. Can it be done with any simple approach like "mv */*.*", or do I need to get a list of all the individual filepaths and feed that to mv?
|
find /src/dir -exec mv '{}' /some/other/dir +;
|
Hi,
try this: Code:
find /path/to/dir -type f -exec mv -n '{}' /path/to/target \; |
I thank both AlucardZero and crts for your help, but it seems that \; is the charm
Code:
g find /home/g/x -exec mv '{}' /home/g/y +; |
Quote:
Linux has no concept of file extensions, both files and directory names can freely contain dots (or not have any at all). |
oop. crts is right in that you want "-type f". And my syntax was slightly wrong, it should be \;.
|
Quote:
your syntax is not wrong; at least the 'find' version (GNU 4.4.2) that I am using accepts it. Although the terminating ';' is not needed when you use '-exec' with a '+', it should not lead to an error if you use it anyway. At least not in bash. Bash will simply interpret it as a line terminator. So possible sources for the error messages can be a 'find' version that does not support '-exec ... +' or maybe executing 'find' in a non-bash terminal. |
All times are GMT -5. The time now is 06:36 AM. |