忘记密码   免费注册 查看新帖 |

ChinaUnix.net

  平台 论坛 博客 认证专区 大话IT HPC论坛 徽章 文库 沙龙 自测 下载 频道自动化运维 虚拟化 储存备份 C/C++ PHP MySQL 嵌入式 Linux系统
最近访问板块 发新帖
查看: 9393 | 回复: 4
打印 上一主题 下一主题

关于Local命令的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-07-06 16:33 |只看该作者 |倒序浏览
local [option] [name[=value] ...]
              For  each  argument,  a  local  variable  named  name is created, and assigned value.  The option can be any of the
              options accepted by declare.  When local is used within a function, it causes the variable name to have  a  visible
              scope  restricted  to  that function and its children.  With no operands, local writes a list of local variables to
              the standard output.  It is an error to use local when not within a function.  The return status is 0 unless  local
              is used outside a function, an invalid name is supplied, or name is a readonly variable.


abc()
{
local a=`echo $haha | awk -F , '{ print $7}'`

....
...
....
}


大家谁能帮忙翻译一下,我翻译完了看不太懂,还有上面这个代码的意思是?  $haha 这个变量就直接这样设置了???

论坛徽章:
0
2 [报告]
发表于 2009-07-06 16:36 |只看该作者
貌似变量继承的意思

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
3 [报告]
发表于 2009-07-06 17:04 |只看该作者

回复 #1 270175100 的帖子

上下文。

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-01-24 06:20:00
4 [报告]
发表于 2009-07-06 17:10 |只看该作者
变量在只在定义它的函数里有效:

[oracle@Minerva practice]$ cat local_variable
abc () {
local a=2
echo "in the function, a=$a"
}

a=1
echo "outside the function, a=$a"
abc
echo "outside of the function, a=$a"
[oracle@Minerva practice]$ local_variable
outside the function, a=1
in the function, a=2
outside of the function, a=1
[oracle@Minerva practice]$

论坛徽章:
0
5 [报告]
发表于 2009-07-06 17:31 |只看该作者

回复 #1 270175100 的帖子

局部变量定义,
您需要登录后才可以回帖 登录 | 注册

本版积分规则

DTCC2018购票6.8折优惠进行时

中国数据库技术大会是国内数据库及大数据领域规模最大、最受欢迎的技术交流盛会。 2018年5月10-12日,第九届中国数据库技术大会将如约而至。本届大会以“数领先机•智赢未来”为主题,设定2大主会场及20个技术专场,邀请来自国内外互联网、金融、教育等行业百余位技术专家,共同探讨Oracle、MySQL、NoSQL、大数据等领域的前瞻性热点话题与技术。
----------------------------------------
优惠时间:2018年2月13日前

报名链接>>
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号 北京市公安局海淀分局网监中心备案编号:11010802020122
广播电视节目制作经营许可证(京) 字第1234号 中国互联网协会会员  联系我们:
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP