shell 的变量作用域
Jul082008
shell变量的作用域
while read line
do
str[$i]=$line1
echo $i
echo ${str[i]}
let i=i+1
done < data
len=${#str[@]}
echo $len
$len长度为实际data文件的行数
str[]变量的作用域一直有效
===================
cat data|while read line
do
str[$i]=$line1
echo $i
echo ${str[i]}
let i=i+1
done
len=${#str[@]}
echo $len
$len长度为0
说明str[]变量的作用域到done结束即失效。
原因是局部变量是普通的变量,仅在创建它的Shell中有效。
cat data|while read line 使用了管道符 “|”
表明父shell中的局部变量不会传递到子shell中
该日志由 2hei 于2008年07月08日发表在 OpenSource, shell 分类下,
原创文章转载请注明: shell 的变量作用域 | 二黑的站点
关键字: shell
原创文章转载请注明: shell 的变量作用域 | 二黑的站点
关键字: shell
您可能还会对这些文章感兴趣!
- 计算1970到今天的天数的shell脚本
- a script of awk array – just mark
- Set Default Value on Shell
- China 省份,城市三级联动数据库
- oracle sqlldr 实际运用中的几个问题
- Shell中标准输出重定向
- lvs ksoftirqd进程占用大量CPU
- 用siege做http的压力测试
- All of Wikipedia can be installed to your desktop in just 30 hours
- 将应用程序添加到右键的方法,just like UE
- how to resove — kernel: mptbase: ioc0: LogInfo
- linux下不错的工具 fping
报歉!评论已关闭.
最新文章
- apache mod_python psp
- Connect to Dell iDRAC6 virtual console
- 使用rrdtoo resize修改已有rrd文件的数据量
- MAC下修改被HP打印机占用的8080端口
- mark: info.3g.qq 宕机
- mark:现在douban.com 豆瓣挂了
- postfix删除mail中的邮件列表
- Mozilla making progress with Firefox’s long journey to multiprocess
- munin监控jmx
- All of Wikipedia can be installed to your desktop in just 30 hours
- Winamp lovers beg AOL to open source code
- Microsoft brings rich node.js support to Visual Studio
- New backdoor worm found attacking websites running Apache Tomcat
- GitHub resets user passwords following rash of account hijack attacks
- Stability first: Ubuntu’s Mir won’t replace X in 14.04 desktop
- lvs ksoftirqd进程占用大量CPU
- monit 一个小巧的linux下监控/故障恢复工具
- nrpe Error: Could not complete SSL handshake. 5
- Canonical “abused trademark law” to target a site critical of Ubuntu privacy
- nagios check_udp 就是一残废
热门文章
- Linux Keyboard shortcut keys - 72,741 views
- mvnforum-1.0.0-rc3+resin+oracle9i下搭建 - 32,234 views
- linux下支持https的压力测试工具 - 19,788 views
- mark: info.3g.qq 宕机 - 17,193 views
- Cacti网络监控软件的安装、配置与使用连载 (2) — By 2hei - 16,206 views
- mark:现在douban.com 豆瓣挂了 - 13,363 views
- New backdoor worm found attacking websites running Apache Tomcat - 13,152 views
- nginx代理模式下,伪造X-Forwarded-For头的测试 - 11,654 views
- Code review 工具gerrit之体验 - 11,194 views
- 关于 - 10,594 views
标签云
alexa
apache
bash
BeautifulSoup
chm
discuz
django
dosevasive
driver
E63
EC2
facebooke
fastdfs
football
freebsd
google
hadoop
hbase
IaaS
java
jvm
kernel
linux
lua
mac
memcached
microsoft's bug
mod_deflate
mod_expires
mt install
mysql
nagios
nginx
openssh
oracle
php
python
R710
resin
rrdtool
shell
siege
ubuntu
vnc
xen
文章分类
- c (5)
- cloud (3)
- database (9)
- dfs (1)
- English (5)
- git (1)
- hbase (2)
- IaaS (2)
- IT (5)
- java (17)
- linux (22)
- live (9)
- nginx (8)
- OpenSource (123)
- other (4)
- others (113)
- php (2)
- python (23)
- resin (17)
- security (4)
- shell (7)
- ubuntu (1)
文章归档
- 2014年2月
- 2013年12月
- 2013年11月
- 2013年10月
- 2013年9月
- 2013年6月
- 2013年5月
- 2013年4月
- 2013年1月
- 2012年9月
- 2012年8月
- 2012年7月
- 2012年5月
- 2011年12月
- 2011年11月
- 2011年10月
- 2011年9月
- 2011年8月
- 2011年7月
- 2011年6月
- 2011年2月
- 2011年1月
- 2010年12月
- 2010年11月
- 2010年10月
- 2010年9月
- 2010年8月
- 2010年7月
- 2010年6月
- 2010年5月
- 2010年4月
- 2010年3月
- 2010年2月
- 2010年1月
- 2009年12月
- 2009年11月
- 2009年9月
- 2009年8月
- 2009年7月
- 2009年5月
- 2009年4月
- 2009年3月
- 2009年2月
- 2008年12月
- 2008年11月
- 2008年10月
- 2008年9月
- 2008年8月
- 2008年7月
- 2008年6月
- 2008年5月
- 2008年4月
- 2008年3月
- 2008年2月
- 2008年1月
- 2007年12月
- 2007年11月
- 2007年10月
- 2007年9月
- 2007年7月
- 2007年6月
- 2007年5月
- 2007年4月
- 2007年3月
- 2007年2月
- 2007年1月
- 2006年12月
最新评论
- 2hei发表在《mark: info.3g.qq 宕机》
- 2hei发表在《mark:现在douban.com 豆瓣挂了》
- 糖糖发表在《换掉Movable Type,启用Worldpress》
- free movie download发表在《sftp get “Connection closed”》
- Emory发表在《nginx代理模式下,伪造X-Forwarded-For头的测试》
- Juegos发表在《pdf and postscript》
- educational grants发表在《some Java decompilers — 一些java反编译工具》
- opthamologists发表在《[notice] child pid 19818 exit signal Bus error (7)》
- irie insurance发表在《linux下支持https的压力测试工具》
- registered nurse发表在《linux下支持https的压力测试工具》
最新日志热评日志随机日志
- apache mod_python psp
- Connect to Dell iDRAC6 virtual console
- 使用rrdtoo resize修改已有rrd文件的数据量
- MAC下修改被HP打印机占用的8080端口
- mark: info.3g.qq 宕机
- mark:现在douban.com 豆瓣挂了
- postfix删除mail中的邮件列表
- Mozilla making progress with Firefox’s long journey to multiprocess
- munin监控jmx
- All of Wikipedia can be installed to your desktop in just 30 hours
- C++中的虚函数(学习)
- Microsoft brings rich node.js support to Visual Studio
- linux下用python实现文本menu
- Node.js-based Ghost blogging platform opens to the public
- proxool与hibernate配置
- All of Wikipedia can be installed to your desktop in just 30 hours
- 关于纹身
- study English every day(2)
- apache mod_deflate 模块使用总结
- shell 的变量作用域
最新评论
糖糖:
埃母梯,是剁么的回晃;埃母梯,是free movie download:
i like it sftp iEmory:
It is very diffiJuegos:
I was surfing loeducational grants:
Thanks for an idopthamologists:
Thanks for someirie insurance:
Great writing! Iregistered nurse:
Wow this is a grliumingzhu:
🙂physical therapist:
It’s really a ni
标签云集
博客统计
- 日志总数:340 篇
- 评论总数:69 篇
- 标签数量:151 个
- 链接总数:0 个
- 建站日期:
- 运行天数:19515 天
- 最后更新:2017-9-18
最活跃的读者