Optimization of SH cssupdate

Source: Internet
Author: User
#!/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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.