#!/bin/bash ## sh ~/go_version.sh 17 ## sh ~/go_version.sh 13 back_file="" if (( "$(uname)"=="Darwin" )) ;then # Mac OS X 操作系统 sed 替换配置文件版本 mac 需要 需要备份源文件 "_bak" back_file="_bak" elif (( "$(expr substr $(uname -s) 1 5)"=="Linux" )) ;then # GNU/Linux操作系统 back_file="" elif (( "$(expr substr $(uname -s) 1 10)"=="MINGW32_NT" )) ;then # Windows NT操作系统 back_file="" fi file='/Users/admin/.bash_profile' go17root='/usr/local/go/go17' go13root='/usr/local/go/go13' if (( "$1" == "17" )); then sed -i "$back_file" "s#$go13root#$go17root#g" "$file" elif (( "$1" == "13" )); then sed -i "$back_file" "s#$go17root#$go13root#g" "$file" else echo "invalid arg" fi