LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 677|回复: 1

请大家给我解释一下这两题

[复制链接]
发表于 2005-4-10 14:05:38 | 显示全部楼层 |阅读模式
1、    $temp='this is a temped variable'; echo ${temp%%is}
执行上述命令的结果为: C
A. th
B. this
C. this is a temped variable
D. this is
%%is 是什么意思啊

13. $my='foofoodfoodfot.jpg'
$echo ${my##*fo}
执行上述命令的结果为:c
A. ofoodfot.jpg
B. odfot.jpg
C. t.jpg
D. .jpg
##*fo是什么意思啊


8. $temp='this is a temped variable'; echo temp<*#*br *#*>执行上述命令的结果为:c
A. temp
B. this is a temped variable
C. 'this is a temped variable'
D. 'this is a temped variable'
<*#*br *#*>是什么意思
发表于 2005-4-10 18:31:57 | 显示全部楼层
1、 $temp='this is a temped variable'; echo ${temp%%is}
执行上述命令的结果为: C
A. th
B. this
C. this is a temped variable
D. this is
%%is 是什么意思啊

首先看一下你的键盘排列,#$%这三个键是不是排在一起,而#是在$的前面,%是在$的后面,所以分别用做掐头去尾,而一个符号表示最小匹配,两个符号表示最大匹配,本题中就是把变量temp中去掉尾部is(最大匹配)。同样第二例第三例自己想想应该就明白了吧?

如果还不是很明确,看一下这个介绍:
http://www.linuxsir.cn/bbs/showthread.php?t=180629
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表