-
-
Save lululau/4595697 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ $ cat test.sh | |
#!/bin/bash | |
function hello() { | |
echo "ARG1: $1" | |
echo "ARG2: $2" | |
echo "ARG3: $3" | |
} | |
echo "ARG_1: $1" | |
echo "ARG_2: $2" | |
echo "ARG_3: $3" | |
echo "ARG_4: $4" | |
shift # 截掉第一个参数 | |
hello "$@" | |
~ $ ./test.sh a b c 'd e' f | |
ARG_1: a | |
ARG_2: b | |
ARG_3: c | |
ARG_4: d e | |
ARG1: b | |
ARG2: c | |
ARG3: d e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我找到解决方法了。
在shell执行的时候参数的写法像这样:
单引号双引号参数值双引号单引号
./test.sh a b c '"d e"' f