【发布时间】:2023-03-17 16:39:02
【问题描述】:
我正在为编辑器做包装器,我部分地遇到了这个错误,我正在检查文件是否已经在某个目录中被编辑过。目录以以下格式存储在文件中:path//date//openCount。双斜杠是分隔符,因为斜杠是类 unix 系统名称中唯一被禁止的字符之一。
/home/test//20150320//1
/home/d3ad/Documents/skola/2015_zima/ios/proj1/ads//20150320//1
/home/d3ad/Documents/skola/2015_zima/ios/proj1/backup.sh//20150320//1
/home/d3ad/Documents/skola/2015_zima/ios/proj1/asd//20150320//7
/home/d3ad/Documents/skola/2015_zima/ios/proj1/bs//20150320//9
代码:
FILE="false"
DIR=$(readlink -f "${2}")
#check if a file was already edited in this directory
for LINE in $(grep -n -o "${DIR}/[^/]*" ${WEDI_RC}); do
if[ -f "${LINE}" ]; then
FILE="true"
fi
done
错误:
./wedi: Syntax error: "then" unexpected (expecting "done")
我尝试删除分号,将“do”和“then”移至下一行,但均未成功。你有什么想法?我很绝望,因为我上面有 1 个 for 循环并且它工作正常。
感谢您的回答
【问题讨论】:
标签: bash for-loop syntax token