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是一个很好的学习范例.
阅读(2972) | 评论(0) | 转发(0) |