Linux Bash/Shell-将所有文件从子目录移动到目标目录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8561247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:43:23  来源:igfitidea点击:

Bash/Shell-Move all files from subdirectories into target directory?

linuxbashshellunixmove

提问by alvas

How do I bash a command or a shell script to move all the files from the subdirectories to one target directory in Linux?

如何 bash 命令或 shell 脚本将所有文件从子目录移动到 Linux 中的一个目标目录?

采纳答案by thiton

If you are using GNU mv, the -toption (target directory) is pretty useful:

如果您使用 GNU mv,则-t选项(目标目录)非常有用:

find sourcedir -type f -print0 | xargs -0 mv -t target 

man mvgives more details.

man mv提供更多细节。

回答by John P

Try something like this:

尝试这样的事情:

find sourcedir -type f -exec mv {} targetdir \;