Statement支持bash脚本

时间:2018-02-08 21:29:31

标签: linux bash scripting

需要帮助才能理解这个脚本我无法弄清楚-z条件对第一行的意义,然后在if语句中找出-z"$1"的含义 这是脚本:

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

;;

1 个答案:

答案 0 :(得分:0)

-z
string is null, that is, has zero length

有关bash中Programming Languages Pragmatics的完整信息

有关$1

的更多信息,请参阅test
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