【发布时间】:2021-10-31 14:43:38
【问题描述】:
我有两个文件名
file1 = "my_random_forest_2021-08-11-094538.csv.zip"
file2 = "my_random_forest_2021-08-11-094538.csv.zip"
if [$file1 == $file2]; then
echo "matched"
在执行脚本时它说:
test.sh: line 5: [my_random_forest_2021-08-11-094538.csv.zip: command not found
如何比较上述格式自带的文件名?
【问题讨论】:
-
如果这真的是 POSIX shell,你也(除了缺少空格)需要使用
=作为操作符,而不是==。详见man test。