Linux Shell编程 for 循环问题
一个文件夹里有30000(00000-30000)个文件,我想把他分到30个文件夹(代码生成)内,并且文件夹名为00000-01000,01001-02000 .....
1、新建00000-30000
#!/bin/bash
#touch
i=0
while [ $i -le 30000 ]
do
touch $(printf "%05d\n" $i)
((i++))
done
2、新建目录及复制文件
#!/bin/bash
i=1
aaa=$i+1
path=/tmp/test/111
path2=/tmp/test/1
#mkdir $path/'0'$i'000''-''0'$aaa'000'
#$i=$[$i+1]
#cp $path2/00* $path/'0'$i'000''-''0'$aaa'000'
for i in $(seq 30);
do
bbb=$[$i-1]
if [ $i -lt 10 ];then
mkdir $path/'0'$bbb'001''-''0'$i'000'
cp $path2/'0'$bbb* $path/'0'$bbb'001''-''0'$i'000'
else
bbb=$[$bbb+1]
i=$[$i-1]
mkdir $path/$i'001''-'$bbb'000'
cp $path2/$i* $path/$i'001''-'$bbb'000'
fi
done
存在的问题:09000-10000 会生成9000-10000
相关推荐
laisean 2020-11-11
xiaonamylove 2020-08-16
luobotoutou 2020-05-19
Jieen 2020-05-18
luobotoutou 2020-04-10
pimshell 2020-02-21
liuyh 2020-08-09
Zaratustra 2020-06-26
applecarelte 2020-06-04
kehanxin 2020-05-26
伏雌摘星阁 2020-04-22
伏雌摘星阁 2020-04-07
酷云的csdn 2020-03-25
Sabrina 2020-03-23
Sabrina 2020-02-16
赵家小少爷 2020-01-04
onetozero 2019-12-19