我正在编写一个 bash 脚本(如下)并使用
sudo bash ./script.bash
结果错误:
line 22: syntax error near unexpected token `fi'
剧本:
getent passwd myuser > /dev/null
if [ $? -eq 0 ]; then
echo "info: user myuser already exists"
else
sudo useradd -M myuser > /dev/null || { echo "ERROR: could not create user myuser."; exit 1 }
echo "info: user myuser created successfully"
fi
如果我删除该行:
|| { echo "ERROR: could not create user fiminion"; exit 1 }
一切似乎都有效..我不明白我错过了什么..:/