【发布时间】:2020-10-23 12:42:15
【问题描述】:
我在 shell 脚本中创建一个函数,我需要传递 2 个参数。一个是路径,另一个是数组。但问题是第二个参数获取的是第一个参数的内容。
例如:
input_files_path="./path"
array=("Word1" "Word2" "Word3")
list_files(){
path=$1
array_in=("${@}")
echo "${array_in[@]}"
}
list_files "${input_files_path}" "${array[@]}"
输出:
./path Word1 Word2 Word3
如果我将第二个参数更改为
array_in=$2
它不起作用。
【问题讨论】:
-
这可能会有所帮助:
help shift
标签: bash shell parameters