如何压缩子目录

jgp*_*jgp 4 directory shell-script

我有一个包含许多子目录的目录。所有这些子目录都包含每个都有唯一名称的文件。我想从所有子目录中取出所有文件并将它们全部移动到一个目录中。

有几百个子目录,所以我不想手动完成。我将如何编写一个 shell 脚本来做到这一点?我正在使用 bash。

enz*_*tib 6

find 是解决方案:

find /srcpath -type f -exec mv {} /dstpath \;
Run Code Online (Sandbox Code Playgroud)

或者更好,如果您mv-t destination-dir选择:

find /srcpath -type f -exec mv -t /dstpath {} +
Run Code Online (Sandbox Code Playgroud)