[英]Randomly select and move 500 directories/folders from a folder to another?
I want to move/copy 500 folders from one directory to another.我想将 500 个文件夹从一个目录移动/复制到另一个目录。 Here, I am not choosing the files randomly but directories/folders.在这里,我不是随机选择文件,而是选择目录/文件夹。
I used the following command to do it, but i am able to mv only a few folders and not 500 folders are moved.我使用以下命令来执行此操作,但我只能移动几个文件夹,而不是移动 500 个文件夹。 Any suggestions on the following command?对以下命令有什么建议吗?
ls | shuf -n 500 | xargs -i mv {} /path-folder/
Use find -type d
to select directories, shuf
to randomize the order, and head -n 500
to select 500 random directories:使用find -type d
到 select 目录, shuf
随机排序, head -n 500
到 select 500 个随机目录:
find . -mindepth 1 -maxdepth 1 -type d | shuf | head -n 500 | xargs -I{} mv {} dest_dir/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.