Linux系统下如批量创建/删除文件和文件夹

(一)批量创建文件夹
mkdir -p /testdata/{data,shell}

ll
drwxr-xr-x 2 root root 4096 9月  25 15:28 data1
drwxr-xr-x 2 root root 4096 9月  25 15:28 data2

(二)批量创建文件
touch test{2019-06,2019-07,2019-08}-{01…05}.txt
{2019-06,2019-07,2019-08} 表示 06,07,08三个月 共3个
{01…05} 表示01-05 共5个

ll
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-06-01.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-06-02.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-06-03.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-06-04.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-06-05.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-07-01.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-07-02.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-07-03.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-07-04.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-07-05.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-08-01.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-08-02.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-08-03.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-08-04.txt
-rw-r--r-- 1 root root    0 9月  25 15:20 test2019-08-05.txt

(三)批量删除文件/文件夹
1、全部删除
rm -rf /testdata/data*

rm -rf /testdata/test*

2、批量删除
rm -rf /testdata/data{1,2}

rm -f /testdata/test2019-07-{01…04}.txt

ll
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-06-01.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-06-02.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-06-03.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-06-04.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-06-05.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-07-05.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-08-01.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-08-02.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-08-03.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-08-04.txt
-rw-r--r-- 1 root root 0 9月  25 15:34 test2019-08-05.txt
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值