sles8-update_rcfile_setting.sh

来自「lustre 1.6.5 source code」· Shell 代码 · 共 36 行

SH
36
字号
# Update the variable $var in $rcfile: The function update_$VAR must# exist. It is called with the old value of $var, and must return the# new value.# update_rcfile_setting() {    local rcfile=$1 var=$2    # The characters $, `, ", and \ have special meaning inside double    # quoted shell variables. The characters " and \ have special meaning    # inside awk double-quoted variables.    local old=$(source "$rcfile" ;    		eval echo \$$var \		| sed -e 's/\([$`"\\]\)/\\\1/g')    local new=$(eval update_$var "$old" \    		| sed -e 's/\([$`"\\]\)/\\\1/g' \		      -e 's/\(["\\]\)/\\\1/g')    local tmp=$(mktemp /tmp/${rcfile##/*}.XXXXXX)        # This script breaks for multi-line varables -- I don't think    # we need to handle this special case.    awk '	function replace() {	    if (!done)		print "'"$var"'=\"'"$new"'\""	    done=1	}		/^'"$var"'=/	{ replace() ; next }			{ print }    ' < $rcfile > $tmp &&    cat $tmp > $rcfile    rm -f $tmp}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?