(命令列第一个参数) $1 如果只等如X, 那就是变量没有内容,是空变量, 也
是用来测试命令列上有没有参数,例如


user@minix-nb:~$ cat a
#! /bin/bash

if [ X$1 = X ]
    then
      echo "the first argu is empty"
    else
      echo "the first argu is $1"
fi

 

user@minix-nb:~$ ./a
the first argu is empty
user@minix-nb:~$ ./a 123
the first argu is 123
user@minix-nb:~$

相关文章:

  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-05-18
  • 2021-11-03
  • 2021-11-18
相关资源
相似解决方案