【发布时间】:2013-08-07 08:37:45
【问题描述】:
我是 R 用户,并且正在尝试将 for 循环与在 bash (FFmpeg) 中运行的程序一起使用。创建一个向量然后在 for 循环中使用该向量对我来说似乎很自然。例如,这就是我在 R 中要做的:
f <- c("File name that is identifier 01.avi", "File name that is identifier 02.avi", "File name that is identifier 03.avi")
for i in 1:length(f) {for loop}
如何在 bash 中为向量分配名称?
这是我尝试并遇到以下问题的方法:
f=["File name that is identifier 01.avi" "File name that is identifier 02.avi" "File name that is identifier 03.avi"]
bash: File name that is identifier 02.avi: command not found
Bash 似乎将我的文件名识别为命令并在这种情况下运行它们
let f=["File name that is identifier 01.avi" "File name that is identifier 02.avi" "File name that is identifier 03.avi"]
bash: let: f=[File name that is identifier 01.avi: syntax error: operand expected (error token is "[File name that is identifier 01.avi")
我显然做错了什么。
如果我只对一个文件执行此操作,它会起作用。有无括号:
f=["File name that is identifier 01.avi"]
# echo $f
[File name that is identifier 01.avi]
【问题讨论】:
标签: bash vector filenames assign