我需要在一堆文件上运行一个脚本,这些文件的路径被分配给train1, train2, ... , train20,我想“为什么不用 bash 脚本让它自动运行呢?”。
所以我做了类似的事情:
train1=path/to/first/file
train2=path/to/second/file
...
train20=path/to/third/file
for i in {1..20}
do
python something.py train$i
done
这不起作用,因为train$iechoestrain1的名称,而不是它的值。
所以我尝试了不成功的事情,比如$(train$i)or ${train$i}or ${!train$i}。有谁知道如何捕捉这些变量的正确值?