bash - Bash argument input changes?
问题描述
I have a bash script that takes in arguments from the command line:
path2self=$(dirname "$(readlink -f "$0")")
path2Intersection=$1
normal=$2
matched=$(echo "$3" | awk '{print tolower($0)}')
csv=$4
f1=$5
f2=$6
f3=$7
f4=$8
r1=$9
path2database=$10
b1=$11
b2=$(echo "$12" | awk '{print tolower($0)}')
b3=$13
echo $path2database
echo $b1
However, if I run it with this:
sh /path/to/script.sh /path/to/Intersection /path/to/normal true /path/to/csv.csv 4 10 0.05 0.01 mut /path/to/databases /path/to/b1 true /path/to/b3
I get this output:
/path/to/Intersection0
/path/to/Intersection1
I don't know why the argument is passing what I send to it through the command line isn't the same. Does anyone know what is going on?
解决方案
$10
最终将作为 和 的值的串联,$1
您'0'
可以在结果中完美地观察到。$11
其他所有超过一位数的情况也是如此。
只需在标识符周围添加花括号即可正确扩展变量 =>${10}
推荐阅读
- angular - 无法绑定到“togglePosition”,因为它不是“mat-expansion-panel”的已知属性
- python - 为什么在设置图标时必须加载文件而不是自定义表面?
- c# - 查看由 .net 应用程序启动的子进程的控制台输出
- python - Python 与使用 pyodbc 的 sql 服务器
- neo4j - 为什么 Neo4j 不在浏览器中显示任何系统信息 (:sysinfo)?
- octobercms - OctoberCMS - 是否可以在后端进行简单的数学运算?
- azure - 有没有办法以编程方式更改 cosmos db 表上的 TTL
- asp.net - foreach 迭代器是在循环之前触发一次还是每次触发一次?
- python - 在 Revit Dynamo 中,我可以将真实图像转换为 numpy 数组吗?
- node.js - npm WARN notsup sequelize@6.1.0 不支持的引擎:想要:{“node”:“>=10.0.0”}