#!/bin/bash# Version: 0.3# Author: linkscue# E-mail: linkscue@gmail.com# function: get key words start line number,$1=key_wordget_start_line(){ # shell function can't return >255 value, so echo replace return echo $(grep -n "$1" $style_file | awk -F':' '{print $1}')}# function: get a style(or sub_style) end line number,$1=line_numberget_end_line(){ echo $(sed -n "$1,/<\/style>/{=}" $style_file | sed -n '$p')}# function: get pattern line number,s1=start s2=end s3=patternget_pattern_line(){ echo $(sed -n -e "$1,$2{/$3/{=;q}}" $style_file)}#function: get a style start and end line numberget_start_end_line(){ echo $(get_start_line "$1") echo $(get_end_line $(get_start_line "$1") )}# error detectif [[ $# != 2 ]]; then #statements echo 'usage: change_xml $style_file $color_file ' exit 1fi# which file will be modified:style_file=$1color_file=$2#style_file=styles.xml#color_file=colors.xml# which style will be changed:theme_main_key='
重写了大部分代码,增强了通用性。