#!/bin/bash # Update the version of the picture within the CSS file # such as Background:url (' images/test.jpg ');
Update to Background:url (' images/test.jpg?20130330121210 '); Csstmpl_path= "/home/fdipzone/php/csstmpl" # CSS Tmpl path css_path= "/home/fdipzone/php/css" # CSS Path replace
Tags= (". png" ". jpg" ". gif") # file type convertnum=0 search_child=$1 # search Child Echo ${search_child:=0} >/dev/null function Create () {tmplfile=$1 dfile=$2 D folder=${dfile%/*} IF [!-D "$dfolder"]; Then mkdir-p $dfolder fi cp "$tmplfile" "$dfile" #复制tmpl到目标文件 for tag in ${repl Acetags[*]};
Do newtag= "$tag $ (date +%y%m%d%h%m%s)" Sed-i "s/$tag/$newtag/g" $dfile "#使用sed-I replacement file contents done convertnum=$ (($convertnum + 1)) Tolog "$tmplfile Convert to $dfile success"} function
Tolog () {echo} function update () { If [-D "$csstmpl _path"] && [D "$css _path"]; Then if ["$search _child"-eq 0]; Then maxdepth= "-maxdepth 1" Else maxdepth= "" Fi for Fil E in $ (Find $csstmpl _path $maxdepth-name "*.css"-type f); Do dfile=${file/$csstmpl _path/$css _path} create $file $dfile done E
Cho "Convert num: $convertnum else Tolog" $csstmpl _path or $css _path not exists "fi}" Update Exit 0
View PHP Version: http://blog.csdn.net/fdipzone/article/details/8570525
View Previous version: http://blog.csdn.net/fdipzone/article/details/8577952
Author: csdn blog proud Snow star Maple
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/