我在Linux上做了两个测试bash脚本,使问题清晰。
TestScript1看起来像:
echo "TestScript1 Arguments:" echo "$1" echo "$2" echo "$#" ./testscript2 $1 $2
TestScript2看起来像:
echo "TestScript2 Arguments received from TestScript1:" echo "$1" echo "$2" echo "$#"
当我以下列方式执行testscript1:
./testscript1 "Firstname Lastname" testmail@domain.com
所需的输出应为:
TestScript1 Arguments: Firstname Lastname testmail@domain.com 2 TestScript2 Arguments received from TestScript1: Firstname Lastname testmail@domain.com 2
但实际输出是:
TestScript1 Arguments: Firstname Lastname testmail@domain.com 2 TestScript2 Arguments received from TestScript1: Firstname Lastname 3
在Testscript中引用你的参数1:
原文链接:https://www.f2er.com/bash/388922.htmlecho "TestScript1 Arguments:" echo "$1" echo "$2" echo "$#" ./testscript2 "$1" "$2"