本版版主招募中

 
标题: ksh第3章
xfc211
LU天使
Rank: 4



UID 790
精华 39
积分 519
帖子 882
活跃指数 -11
LU金币 1905 个
LU金条 0 个
阅读权限 80
注册 2003-10-20
 
发表于 2003-11-10 15:41  资料  个人空间  短消息  加为好友 
第3章
变量和参数
$X=abc
$X= 设为空
$typeset X=abc

访问变量
$print $X
abc
变量属性
typese –attribute variable=value
or
typese –attribute variable
大小写属性
$typese –l X=ABC
$print $X
abc

$typese u X
$print $X
ABC

只读属性
$typeset -r NUM=2
$ print $NUM
$2
$NUM=22
$ksh: NUM: is read only

整数属性
$ typeset -i NUM=22
$ print $NUM
$22

float属性(-E -F)
$ typeset -E5 C=123.345
$ print $C
$ C=123.35

$ typeset -F5 C=123.345
$ print $C
$ C=123.34500

Right and left justify attributes
# typeset -R7 A=10 B=10000
# print $A
10
# print $B
10000
# typeset -R3 A=10 B=10000
# print $A
10
# print $B
000

自动输出属性
$typeset X=abc
$export X
等价于
$typeset -x X=abc

删去属性
$typeset +i NUM

设置多个属性
$typeset –xi X=abc

属性检查
# typeset -i
ERRNO=2
LINENO=1
MAILCHECK=600
NUM=2
OPTIND=1
PPID=13843
RANDOM=6084
SECONDS=2314
TMOUT=0
# typeset -r
NUM=2

变量其它属性
$ Y=$NUM
$print $Y
2

# UCSC=$(grep abc /etc/hosts | cut -f1)
# print $UCSC
192.168.0.2

unsetting variables
$unset UCSC
$print $UCSC
$

顶部
 



当前时区 GMT+8, 现在时间是 2008-11-23 18:25
乐悠LoveUnix论坛-京ICP备05005823号

Thanks to Discuz!  © 2001-2007    Power by LoveUnix.net
Processed in 0.050085 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - 乐悠LoveUnix - Archiver