Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Bash/Shell是否将所有文件从子目录移动到目标目录?_Linux_Bash_Shell_Unix_Move - Fatal编程技术网

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

Linux Bash/Shell是否将所有文件从子目录移动到目标目录?,linux,bash,shell,unix,move,Linux,Bash,Shell,Unix,Move,在Linux中,如何使用bash命令或shell脚本将所有文件从子目录移动到一个目标目录?尝试以下操作: find sourcedir -type f -exec mv {} targetdir \; 如果您使用的是GNU mv,-t选项(目标目录)非常有用: find sourcedir -type f -print0 | xargs -0 mv -t target manmv提供了更多细节。我已经尝试了thiton和john的解决方案。“麻烦”很有效。我喜欢老派的想法,把我的发现放

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

尝试以下操作:

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

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

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

manmv
提供了更多细节。

我已经尝试了thiton和john的解决方案。“麻烦”很有效。我喜欢老派的想法,把我的发现放到xargs上,然后进行mv。
-exec mv{}
同样工作良好