shell 判斷字符串長度是否為0


 

test.sh

#!/bin/bash
echo "enter the string:"
read filename
if test -z $filename ; then
echo "the length is 0"
else
echo "the length is not 0"
fi

執行

sudo chmod +x test.sh
./test.sh

輸出

enter the string:

the length is 0

 

執行

./test.sh

輸出

enter the string:
sssssss
the length is not 0

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM