sh cssupdate 优化

来源:互联网 发布:淘宝如何复制宝贝 编辑:程序博客网 时间:2024/05/22 06:10
#!/bin/bash# 更新css文件内图片的版本# 如background:url('images/test.jpg'); 更新为 background:url('images/test.jpg?20130330121210');csstmpl_path="/home/fdipzone/php/csstmpl" # css tmpl pathcss_path="/home/fdipzone/php/css"         # css pathreplacetags=(".png" ".jpg" ".gif")        # file typeconvertnum=0search_child=$1                           # search childecho ${search_child:=0} > /dev/nullfunction create(){    tmplfile=$1    dfile=$2    dfolder=${dfile%/*}    if [ ! -d "$dfolder" ]; then        mkdir -p $dfolder    fi    cp "$tmplfile" "$dfile" #复制tmpl到目标文件    for tag in ${replacetags[*]} ; do        newtag="$tag?$(date +%Y%m%d%H%M%S)"        sed -i "s/$tag/$newtag/g" "$dfile" #使用sed -i 替换文件内容    done    convertnum=$(($convertnum+1))    tolog "$tmplfile convert to $dfile success"}function tolog(){    echo $1}function update(){    if [ -d "$csstmpl_path" ] && [ -d "$css_path" ]; then                if [ "$search_child" -eq 0 ]; then            maxdepth=" -maxdepth 1 "        else            maxdepth=""        fi        for file in $(find $csstmpl_path $maxdepth -name "*.css" -type f) ; do            dfile=${file/$csstmpl_path/$css_path}            create $file $dfile        done        echo "convert num: $convertnum"    else        tolog "$csstmpl_path or $css_path not exists"    fi}updateexit 0

查看PHP版

查看上一版

原创粉丝点击