[英]Linux basic shell scripting
So I need my while loop to continually loop but it stops after the first user's input, example: 所以我需要我的while循环来不断循环,但是在第一个用户输入后它会停止,例如:
[user]$: ./pleasefix.sh [用户] $:./ pleasefix.sh
Enter Input:test 输入Input:test
test is writeable. 测试是可写的。
[user]$: [用户] $:
Heres my script as it is: 这是我的脚本,它是:
if [ "$#" -ne 0 ]
then
echo "$0" "is expecting no arguments; found $# $*"
echo "Usage: "$0""
exit 2
fi
while read -p "Enter Input:" userString
do
if [ -w "$userString" ]
then
echo ""$userString" is writeable."
exit 0
else
echo ""$userString" is nonexistent or not writeable."
exit 1
fi
done
What can I add to my while to make it actually loop and re prompt the user for another file name? 我可以添加什么时间使它真正循环并重新提示用户输入另一个文件名? Basically I want it to last forever until a EOF is sent (crtl + D)
基本上我希望它能一直持续到发送EOF(crtl + D)
从exit 0
exit 1
出
You are using "exit" at both case if-else. 您在两种情况下都使用“ exit” if-else。 You can remove one of them.
您可以删除其中之一。
Remove the "exit 0" and the "exit 1"? 删除“出口0”和“出口1”? Those will cause it to exit your script.
这些将导致它退出您的脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.