set-pos.sh

来自「Shall高级编程」· Shell 代码 · 共 39 行

SH
39
字号
#!/bin/bashvariable="one two three four five"set -- $variable# Sets positional parameters to the contents of "$variable".first_param=$1second_param=$2shift; shift        # Shift past first two positional params.# shift 2             also works.remaining_params="$*"echoecho "first parameter = $first_param"             # oneecho "second parameter = $second_param"           # twoecho "remaining parameters = $remaining_params"   # three four fiveecho; echo# Again.set -- $variablefirst_param=$1second_param=$2echo "first parameter = $first_param"             # oneecho "second parameter = $second_param"           # two# ======================================================set --# Unsets positional parameters if no variable specified.first_param=$1second_param=$2echo "first parameter = $first_param"             # (null value)echo "second parameter = $second_param"           # (null value)exit 0

⌨️ 快捷键说明

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