diffnest / myblog

0 stars 0 forks source link

一段批量创建文件夹的shell #7

Open diffnest opened 7 years ago

diffnest commented 7 years ago

每次新配置一台服务器都会用到批量创建图片文件夹,在此记录下,方便下次直接copy paste

#!/bin/sh
path='/var/ProjectB/photo'
for((i = 0; i < 100; i ++)) 
    do
        len=`expr length $i`;
        if [ $len -eq 1 ] 
            then
               p="0"$i 
            else    
               p=$i;
        fi 

        for((j = 0; j < 100; j ++))
        do  
            len1=`expr length $j`;
            if [ $len1 -eq 1 ] 
                then
                    c=$p"/0"$j
                else
                    c=$p"/"$j;
            fi  
            #echo $path'/'$c
            mkdir -p $path'/'$c;
        done
    done