Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15343561
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2008-12-24 10:51:00

exec < infile 默认赋值给lib库中的文件描述符0
exec > outfile 默认从lib库中的文件描述符1输出
exec > outfile 2> errfile 将2描述符erro信息输出到文件errfile

exec 3
$ read line1 < names; echo $line1; read line2 < names; echo $line2
Alice Jones
Alice Jones

$ (read line1; echo $line1; read line2; echo $line2) < names
Alice Jones
Robert Smith

$ exec 3< names
$ read -u3 line1; echo $line1; read -u3 line2; echo $line2
Alice Jones
Robert Smith
$ exec 3<&-

$ to_screen1 > out 2> err
message to the user
$ cat out
message to standard output
$ cat err


luther@gliethttp:~$ exec 9<&0 Help
on
module struct:
NAME
luther@gliethttp:~$ cat struct.c
Help on module struct:
NAME
    struct
FILE
    /usr/lib/python2.5/struct.py
MODULE DOCS
    http://www.python.org/doc/current/lib/module-struct.html
所以read可以根据tab,空格等来进一步细分,读取一行中的某几个域,这在ubuntu7.10的/lib/init/mount-functions.sh是一个很好的学习范例.


阅读(2907) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~