2
我必须修改现有的ksh脚本,它使用'shift'查看命令行参数,并清空$ @,但现在要将原始参数传递给之后的第二个剧本。将ksh输入数组存储到变量并传递给另一个脚本
在主线情况下,我可以通过将$ @复制到一个变量并将其传递给第二个脚本来完成此操作,但是我无法让它适用于引用的命令行参数。
如果我有一个叫做 '打印机' 像下面的脚本:
#!/bin/ksh
[email protected]
echo "Printing args"
until [[ $# -eq 0 ]];do
echo $1
shift
done
./printer2 $INPUT
和PRINTER2象下面这样:
#!/bin/ksh
echo "Printing second args"
until [[ $# -eq 0 ]];do
echo $1
shift
done
我想的
./printer first second "third forth"
输出为:
Printing args
first
second
third forth
Printing second args
first
second
third forth
我试过各种各样的变量组合(在$ INPUT的赋值和将它传递给printer2时),但无法弄清楚。谁能帮忙?
与我的兴趣有关。感谢您的帮助! – Katerberg 2011-01-21 21:20:24
请参阅http://unix.stackexchange.com/questions/41357/what-is-the-most-correct-way-to-pass-an-array-to-a-function进行推理。 – 2012-08-31 13:57:10