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:~$

posted @ 2012-09-19 18:09  google4y  阅读(1452)  评论(0编辑  收藏  举报
不在家,就在公司,不在公司,就在去公司的路上,無家無根,如風如萍,只有漂