Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 作为另一个bash脚本动态调用参数的bash脚本_Linux_Bash - Fatal编程技术网

Linux 作为另一个bash脚本动态调用参数的bash脚本

Linux 作为另一个bash脚本动态调用参数的bash脚本,linux,bash,Linux,Bash,我想实现一个bash脚本,其作用如下 ./script_a.sh script_b.sh $arg1 $arg2 ... ./script\u a.sh script\u b.sh$arg1$arg2。。。 ./script_a.sh将调用$arg1$arg2上的script_b.sh$阿尔金 我不知道事先有多少个arg。这怎么可能是一个呢?试试这个包装器: #!/bin/bash "$@" 尝试将此作为包装: #!/bin/bash "$@" $@包含传递给脚本的所有参数的列表 例如,考虑

我想实现一个bash脚本,其作用如下

./script_a.sh script_b.sh $arg1 $arg2 ... ./script\u a.sh script\u b.sh$arg1$arg2。。。 ./script_a.sh将调用$arg1$arg2上的script_b.sh$阿尔金 我不知道事先有多少个arg。这怎么可能是一个呢?

试试这个包装器:

#!/bin/bash
"$@"
尝试将此作为包装:

#!/bin/bash
"$@"

$@
包含传递给脚本的所有参数的列表

例如,考虑:

-sh-3.2$ cat scripta
echo $@
"./$@"

-sh-3.2$ cat scriptb
echo hello world $@

-sh-3.2$ bash scripta scriptb 1 2 3 4
scriptb 1 2 3 4
hello world 1 2 3 4
“/$@”
调用参数中的脚本,
scriptb
使用剩余参数
1 2 3 4


hello world 1 2 3 4
是在运行第二个sript时获得的,
scriptb

$@
包含传递给脚本的所有参数的列表

例如,考虑:

-sh-3.2$ cat scripta
echo $@
"./$@"

-sh-3.2$ cat scriptb
echo hello world $@

-sh-3.2$ bash scripta scriptb 1 2 3 4
scriptb 1 2 3 4
hello world 1 2 3 4
“/$@”
调用参数中的脚本,
scriptb
使用剩余参数
1 2 3 4


hello world 1 2 3 4
是在运行第二个sript时获得的,
scriptb

是否已经实现了
script_b.sh
,或者这是一个新的设计?如果是,为什么要这样做?是
script_b.sh
已经实现了,还是这是一个全新的设计?如果是,你为什么要这样做?