免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: r2007
打印 上一主题 下一主题

shell的输入与输出  关闭 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2005-08-02 22:06 |只看该作者

shell的输入与输出

Redirector Function

cmd1 | cmd2
Pipe; take standard output of cmd1 as standard input to cmd2

> file
Direct standard output to file

< file
Take standard input from file

>> file
Direct standard output to file; append to file if it already exists

>| file
Force standard output to file even if noclobber is set

n>| file
Force output to file from file descriptor n even if noclobber is set

<> file
Use file as both standard input and standard output

n<> file
Use file as both input and output for file descriptor n

<< label
Here-document; see text

n> file
Direct file descriptor n to file

n< file
Take file descriptor n from file

n>> file
Direct file descriptor n to file; append to file if it already exists

n>&
Duplicate standard output to file descriptor n

n<&
Duplicate standard input from file descriptor n

n>&m
File descriptor n is made to be a copy of the output file descriptor

n<&m
File descriptor n is made to be a copy of the input file descriptor

&>file
Directs standard output and standard error to file

<&-
Close the standard input

>&-
Close the standard output

n>&-
Close the output from file descriptor n

n<&-
Close the input from file descriptor n

论坛徽章:
0
22 [报告]
发表于 2005-08-03 14:02 |只看该作者

shell的输入与输出

:em11:

论坛徽章:
0
23 [报告]
发表于 2006-02-16 00:09 |只看该作者
看了不能白看,学了不能白学。
谢谢了!

论坛徽章:
0
24 [报告]
发表于 2006-03-15 08:56 |只看该作者
看了好久,终于明白了,谢谢!

论坛徽章:
0
25 [报告]
发表于 2006-08-22 17:45 |只看该作者
exec 9>&1
ls -l yes no 2<&1 1<&9 9<&-  | cat >err 9<&-
exec 9>&-

这段脚本与楼主的脚本作用一致
也说明n>&m 与 n<&m地作用其实是一样的,都是将文件描述符数组的m号单元的内容复制到n号单元

论坛徽章:
0
26 [报告]
发表于 2006-08-22 18:45 |只看该作者
长见识

论坛徽章:
0
27 [报告]
发表于 2007-03-17 21:58 |只看该作者
看旧贴,学知识!

论坛徽章:
0
28 [报告]
发表于 2007-03-19 11:12 |只看该作者
学习

论坛徽章:
0
29 [报告]
发表于 2007-04-08 14:35 |只看该作者
太精彩了!!

论坛徽章:
0
30 [报告]
发表于 2008-07-09 14:32 |只看该作者
学习.... 
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP