【发布时间】:2019-01-19 08:34:10
【问题描述】:
我只想在文件名以.request 结尾时调用函数,但如果request 是子字符串,它会以某种方式调用该函数。
我marked with red and green导入的部分,右边是输出
for file in ${filesOrDir[*]}; do
if [[ -f "$file" ]]; then
if [[ "$file"=*[".request"] ]]; then
# Enters here when .request is a substring.
fi
fi
if [[ -d "$file" ]]; then
# ... some logics
fi
done
【问题讨论】:
-
图中有截图
-
提供代码
-
[[ $file = *.request ]]? -
更好还是我应该把整个脚本?
标签: string bash shell string-matching