m0_70630059
2022-06-17 09:16
采纳率: 0%
浏览 27

shell脚本sh文件,显示未预期的文件结尾错误

#!/bin/bash
echo 1.注册
echo 2.登录
echo 3.退出
read -p "请输入选择": num
case $num in
1)
echo "欢迎来到注册界面"
read -p "请输入用户名": user
read -p "请输入密码": password
read -p "请输入密码": password2

while read line
do
Nuser=echo $line | cut -d ":" -f 1
if [ "$user" == "$Nuser" ];then
echo "用户名已存在"
exit 1
fi
done < /yubo/shell/wenjian.txt
if [ "${#user}" -ge 3 -a "${#password}" -ge 4 ]
then
if [ "${password}" == "${password2}" ]
then
echo "${user}:${password}" >> /yubo/shell/wenjian.txt
echo "恭喜你注册成功"
else
echo "两次密码不一致"
fi
fi
;;
2)
echo "欢迎来到登录界面"
read -p "请输入用户名": Luser
read -p "请输入密码": Lpassword
up="${Luser}:${Lpassword}"

lines=cat /yubo/shell/wenjian.txt | wc -l
i=1
while read line
do
if [ "${up}" == "${line}" ]
then
echo "登录成功"
exit 0

这是别人的代码,然后显示未预期的文件结尾,后面我在最后边添加了fi 和 done,但是还是同样的错误,有什么办法可以解决这个问题吗?求告知

2条回答 默认 最新

相关推荐 更多相似问题