首页 > 解决方案 > 为什么在我的 Bash 脚本中出现“意外标记‘完成’附近的语法错误”?

问题描述

我有这个 Bash 脚本:

#!/bin/bash

while read -r line; do
    ip="$line"
    torify ./PRET/pret.py $ip pjl -q -i ./commands.txt
done < "./potential_bros.txt"

为什么我会收到此错误?

命令.txt=

print ./message.pdf
display Completed
quit

potential_bros.txt = 我的 ip

PRET = https://github.com/RUB-NDS/PRET

标签: bash

解决方案


我无法重现此错误。有效的例子:

$ cat t.sh
while read -r line ; do
  echo $line
done  < t.txt

$ cat t.txt
item1
item2
item3

$ ./t.sh
item1
item2
item3

推荐阅读