So I need my while loop to continually loop but it stops after the first user's input, example:
[user]$: ./pleasefix.sh
Enter 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)
从exit 0
exit 1
出
You are using "exit" at both case if-else. You can remove one of them.
Remove the "exit 0" and the "exit 1"? Those will cause it to exit your script.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.