需要帮助理解这个脚本,我不明白-z
是什么条件意味着第一行然后 -z
与 "$1"
在 if 语句中
这是脚本:
while [ -z "$USERNAME" ]
do
if [ -z "$1" ]
then
unset ans
unset USER
echo "What is the username you would like to add?"
read USER
echo "Is" $USER " the correct username? [y/n]"
read ans
case "$ans" in
y|Y|yes|Yes|YES)
USERNAME=$USER
;;
最佳答案
-z
string is null, that is, has zero length
有关 test 的完整信息在bash中
请参阅special variables了解有关 $1
的更多信息。
Arguments passed to the script from the command line [1] : $0, $1, $2, $3 . . .
$0 is the name of the script itself, $1 is the first argument
关于linux - While 语句有助于 bash 脚本编写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48695087/