shell中的X的用法

(命令列第一个参数) $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:~$

原文地址:https://www.cnblogs.com/google4y/p/2694114.html