1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
if [ "$1" != "mode1" -a "$1" != "mode2" ];then echo "tip:─┬─────── 您输入参数不对,请重试:" echo " │─────── 'mode1', 使用config/mode1.sh的配置" echo " └─────── 'mode2', 使用config/mode2.sh的配置" exit 0 fi
case $1 in mode1) . config/mode1.sh ;; mode2) . config/mode2.sh ;; *) echo "Usage: sh main.sh [mode1|mode2]" exit; esac
content_url_old=$(awk -F"\"" '/content_url/{print $4}' example.json) sed -e "s@$content_url_old@$content_url_new@g" -i example.json
enable_feature1_line=$(awk -F"\"" '/enable_feature1/{print NR}' example.json) enable_feature1_old=$(awk -F"\"" '/enable_feature1/{print $4}' example.json) sed -e "$enable_feature1_line s@$enable_feature1_old@$enable_feature1_new@" -i example.json
enable_feature2_line=$(awk -F"\"" '/enable_feature2/{print NR}' example.json) enable_feature2_old=$(awk -F"\"" '/enable_feature2/{print $4}' example.json) sed -e "$enable_feature2_line s@$enable_feature2_old@$enable_feature2_new@" -i example.json
|