当前位置:网站首页>使用shell将一个目录的所有文件移动以年月为名的文件夹中
使用shell将一个目录的所有文件移动以年月为名的文件夹中
2022-07-21 11:30:00 【aerror】
首先创建一个临时的目录:
mkdir tempformv
使用stat,cut和mkdir创建以月份为名的文件夹
$stat -c "%y" * | cut -b1-7 | sort | uniq | while read line ;do mkdir tempformv/$line; done
$ls tempformv/
2010-05 2020-05
生成要执行的命令
$ stat -c 'TT="%y";FN="%n"' * | grep -v tempformv | while read line; do eval "$line"; echo "mv \"${FN}\" \"tempformv/${TT:0:7}/\""; done > tempformv/mvops.sh
检查一下生成的命令
cat tempformv/mvops.sh
无误后,执行命令
chmod +x tempformv/mvops.sh
tempformv/mvops.sh
把文件从temp目录移回来
mv tempformv/* .
完成
边栏推荐
- Corrilization of scala functions
- 32位栈溢出进阶
- Yan Weimin Chapter II answers to exercises after class
- gadget之usb_function
- [CCF CSP] 201709-1 dozen soy sauce
- 【CCF CSP】201512-1数位之和
- MysqlWorkBench性能分析工具--性能仪表盘
- 50 places are limited to open | with the news of oceanbase's annual press conference coming!
- 10 papers of ant security laboratory were included by ccf-a top meeting to explore the realization of AI credibility from the perspective of algorithm
- 50个名额限量开放|带着OceanBase年度发布会的消息走来了!
猜你喜欢
50个名额限量开放|带着OceanBase年度发布会的消息走来了!
第三章课后习题24-33
2.3线性表的链式表示(2)
50 places are limited to open | with the news of oceanbase's annual press conference coming!
Web
[CCF CSP] 201903-1 small, medium and large
2.2线性表的顺序表示
中厂败走菜篮子
即时零售三国杀:美团补仓、阿里协同、京东引流
【黑马早报】苏宁张康阳败诉,被“追债”17亿;恒驰总裁称恒驰大卖已成定局;iPhone14ProMax镜头激凸严重;微信支持全屏输入...
随机推荐
PAM4科普
即时零售三国杀:美团补仓、阿里协同、京东引流
gadget之usb_gadget
[CCF CSP] 201609-1 maximum fluctuation
Baidu world 2022, see you tomorrow!
Web
[CCF CSP] 201604-1 break point count
C#程序设计经典教程
Collation of common tools in commons Lang
Hutool工具类和工具方法
Yan Weimin Chapter II after class exercises (2.29-2.38)
The use of anonymous inner classes in development
Chapter III after class exercises 24-33
BUUCTF-pwn[1]
Shell programming foundation and variables
32位栈溢出进阶
2.3线性表的链式表示(2)
Excel实操笔记1
【CCF CSP】201712-1最小差值
Upload and download Excel files from the browser to the database