我想要實現的行爲方式如下bash腳本,動態調用參數作爲另一個bash腳本
./script_a.sh script_b.sh $arg1 $arg2 ...
./script_a.sh將調用上$ ARG1 $ ARG2 script_b.sh bash腳本... $ argn 我不知道之前有多少個參數。這怎麼可能是一個?
我想要實現的行爲方式如下bash腳本,動態調用參數作爲另一個bash腳本
./script_a.sh script_b.sh $arg1 $arg2 ...
./script_a.sh將調用上$ ARG1 $ ARG2 script_b.sh bash腳本... $ argn 我不知道之前有多少個參數。這怎麼可能是一個?
試試這個作爲包裝:
#!/bin/bash
"[email protected]"
的[email protected]
包含傳遞給腳本的所有參數列表。
例如考慮:
-sh-3.2$ cat scripta
echo [email protected]
"./[email protected]"
-sh-3.2$ cat scriptb
echo hello world [email protected]
-sh-3.2$ bash scripta scriptb 1 2 3 4
scriptb 1 2 3 4
hello world 1 2 3 4
"./[email protected]"
調用腳本中的說法,scriptb
與其餘的參數1 2 3 4
hello world 1 2 3 4
上運行的第二sript獲得,scriptb
是'script_b。 sh'已經實施了,還是這是一個全新的設計?如果是這樣,你爲什麼要這樣做? – ghostdog74 2014-10-30 07:08:56