#子目录按年月日命令,对每个月的子目录进行打包 y='2023' #定义年份 for m in {01..12};do #定义01到12月 ym="$y$m" echo $ym if ls $ym* &> /dev/null;then #检查月份文件夹是否存在 echo "$ym* exists,start to tar..." tar -cf $ym.tar $ym* else echo "$ym* not exists." fi done
目录格式如下:
标签:01,ym,exists,tar,月份,echo,目录,打包 From: https://www.cnblogs.com/dreamer-fish/p/17769205.html