簡體   English   中英

Linux基本Shell腳本

[英]Linux basic shell scripting

所以我需要我的while循環來不斷循環,但是在第一個用戶輸入后它會停止,例如:

[用戶] $:./ pleasefix.sh

輸入Input:test

測試是可寫的。

[用戶] $:

這是我的腳本,它是:

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

我可以添加什么時間使它真正循環並重新提示用戶輸入另一個文件名? 基本上我希望它能一直持續到發送EOF(crtl + D)

exit 0 exit 1

您在兩種情況下都使用“ exit” if-else。 您可以刪除其中之一。

刪除“出口0”和“出口1”? 這些將導致它退出您的腳本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM