优麒麟技术论坛

 找回密码

求高手帮忙优化Shell脚本 [复制链接]

编了一个在安卓手机,终端上运行的Shell脚本,执行效率不高,运行耗时。想优化提速。
请高手指点。


# 查找小于300k且15天内没有被访问/修改过的文件(atim -n,n天内没被访问过;atim +n,n天之前没被访问过)
echo "   开始清理SD卡中影音图片小文件,稍等..."
smallfile_1[0]=`$find_2 $sd \( -path $sd/Books -o -path $sd/DCIM -o -path $sd/Download -o -path $sd/Pictures -o -path $sd/WechatXposed \) -prune -o \( -atime +15 -o -mtime +15 \) -type f -size -300k 2>/dev/null|sed -e '/.nomedia/ d' -e '/\/0\/Books/ d' -e '/\/0\/DCIM/ d' -e '/\/0\/Download/ d' -e '/\/0\/Pictures/ d' -e '/\/0\/WechatXposed/ d' -e '/\/0\/com.tencent.tmgp.sgame/ d' -e '/\/MIUI\/theme\/.data/ d'` &
smallfile_1[1]=`$find_2 /data/data \( -atime +15 -o -mtime +15 \) -type f -size -300k 2>/dev/null|sed -e '/.nomedia/ d'` &
for smallfile_2 in ${smallfile_1
  • };
    do
      { smallfile_3=`file "$smallfile_2" 2>/dev/null | $awk_2 '{print $2}'`;
      [[ $smallfile_3 == "empty" || $smallfile_3 == "BMP" || $smallfile_3 == "GIF" || $smallfile_3 == "ICO" || $smallfile_3 == "JPEG" || $smallfile_3 == "JPG" || $smallfile_3 == "PCX" || $smallfile_3 == "PNG" || $smallfile_3 == "SWF" || $smallfile_3 == "SVG" || $smallfile_3 == "TIF" || $smallfile_3 == "TIFF" || $smallfile_3 == "WEBP" || $smallfile_3 == "WMF" || $smallfile_3 == "3GP" || $smallfile_3 == "AAC" || $smallfile_3 == "ASF" || $smallfile_3 == "ASX" || $smallfile_3 == "AVI" || $smallfile_3 == "FLAC" || $smallfile_3 == "FLV" || $smallfile_3 == "MKV" || $smallfile_3 == "MPEG" || $smallfile_3 == "MP3" || $smallfile_3 == "MP4" || $smallfile_3 == "WMV" ]] && (rm -f \"$smallfile_2\" 1>/dev/null 2>>$sd/adzw_7_err.txt;[[ $? == "0" ]] && echo $smallfile_2 >>$sd/adzw_7.txt);} &
    done

  • 发表于 2021-2-7 15:10:36
    回复

    使用道具 举报

    求高手帮忙优化Shell脚本 [复制链接]


     楼主| 发表于 2021-2-7 15:15:14
    回复

    使用道具 举报

    小黑屋|手机版|Archiver|Ubuntu Kylin    

    GMT+8, 2021-3-5 08:39 , Processed in 0.018662 second(s), 18 queries .

    Copyright ©2013-2021 Ubuntu Kylin. All Rights Reserved .

    ICP No. 15002470-2 Tianjin

    快速回复 返回顶部 返回列表