shell cp 复制时限制文件个数

场景介绍

我的 web 自动化脚本截取了大量页面图片并将它们存储到了阿里 oss,这是它们部分文件的目录结构:

➜  target_post_sponsored tree
.
├── 100110425921069
│   ├── 20220524_000930-100000872442821-100110425921069-undefined.jpeg
│   ├── 20220524_000930-100000872442821-100110425921069-undefined.txt
│   ├── 20220524_002915-100038712511871-100110425921069-undefined.jpeg
│   ├── 20220524_002915-100038712511871-100110425921069-undefined.txt
│   ├── 20220524_004010-100025417368265-100110425921069-undefined.jpeg
│   ├── 20220524_004010-100025417368265-100110425921069-undefined.txt
├── 100135292582020
│   ├── 20220524_002522-100011298013085-100135292582020-undefined.jpeg
│   ├── 20220524_002522-100011298013085-100135292582020-undefined.txt
│   ├── 20220524_014404-100027839841782-100135292582020-undefined.jpeg
│   ├── 20220524_014404-100027839841782-100135292582020-undefined.txt
│   ├── 20220524_014504-100021851123313-100135292582020-undefined.jpeg
│   └── 20220524_014504-100021851123313-100135292582020-undefined.txt
├── 100186909103642
│   ├── 20220524_001321-100005681042725-100186909103642-undefined.jpeg
│   ├── 20220524_001321-100005681042725-100186909103642-undefined.txt
│   ├── 20220524_001437-100011647093642-100186909103642-undefined.jpeg
│   ├── 20220524_001437-100011647093642-100186909103642-undefined.txt
│   ├── 20220524_021322-100041389577175-100186909103642-undefined.jpeg
│   ├── 20220524_021322-100041389577175-100186909103642-undefined.txt

图片文件名组成: YYYYMMDD_hhmmss-pId-iId-tId.jpeg ,我需要复制 2022 年 5 月 24 日 8 ~ 9 点时段的图片到其他目录,并且数量为 200 张。

shell 命令

pwd
/Users/cjs/oss/v3/2022/05/24/target_post_sponsored
# 上面部分展示了我所在的目录

# 实际执行的命令
cp `find ./*/20220524_08*.jpeg -maxdepth 1 -type f | tail -200` ~/Desktop/24/
展示评论