Advanced redirection features
来源:互联网 发布:js navigator 编辑:程序博客网 时间:2024/05/16 07:33
here are three types of I/O, which each have their own identifier, called a file descriptor:
standard input: 0
standard output: 1
standard error: 2
In the following descriptions, if the file descriptor number is omitted, and the first character of the redirection operator is <, the redirection refers to the standard input (file descriptor 0). If the first character of the redirection operator is >, the redirection refers to the standard output (file descriptor 1).
Some practical examples will make this more clear:
ls > dirlist 2>&1
will direct both standard output and standard error to the file dirlist, while the command
ls 2>&1 > dirlist
will only direct standard output to dirlist. This can be a useful option for programmers.
Things are getting quite complicated here, don't confuse the use of the ampersand here with the use of it inSection 4.1.2.1, where the ampersand is used to run a process in the background. Here, it merely serves as an indication that the number that follows is not a file name, but rather a location that the data stream is pointed to. Also note that the bigger-than sign should not be separated by spaces from the number of the file descriptor. If it would be separated, we would be pointing the output to a file again. The example below demonstrates this:
[nancy@asus /var/tmp]$ ls 2> tmp[nancy@asus /var/tmp]$ ls -l tmp-rw-rw-r-- 1 nancy nancy 0 Sept 7 12:58 tmp[nancy@asus /var/tmp]$ ls 2 > tmpls: 2: No such file or directory
The first command that nancy executes is correct (eventhough no errors are generated and thus the file to which standard error is redirected is empty). The second command expects that 2 is a file name, which does not exist in this case, so an error is displayed.
All these features are explained in detail in the Bash Info pages.
- Advanced redirection features
- Understanding advanced SQL features
- Open vSwitch Advanced Features Tutorial
- Redirection
- gdb教程:6. Advanced gdb Features
- Yahoo! Hadoop Module 5: Advanced MapReduce Features
- Get Acquainted with the New Advanced Features of JUnit 4
- Get Acquainted with the New Advanced Features of JUnit 4
- Core Java 2, Volume II: Advanced Features, Seventh Edition
- Core Java, Vol. 2: Advanced Features, 8th Edition
- 课程 Java程序设计7:Advanced Class Features (怀旧版)
- Linux vi and vim editor: Tutorial and advanced features
- Java —— Advanced Language Features —> static
- Features
- Features
- netwok redirection
- Query uses advanced features that you don’t have access to
- How-To: Run a MapReduce Job in CDH4 using Advanced Features
- android activity的生命周期,四种启动模式
- cmd命令大全
- centos下安装zend扩展
- ffplay for mfc 代码备忘
- oracle乱码
- Advanced redirection features
- struts2学习笔记之十三(数据标签)
- 主元素问题(随机算法)
- win32 cocos2d-x-2.2.5建立项目
- android 字体的设置
- [leetcode] Search in Rotated Sorted Array
- 一个简单的圆形图片实现
- Freemarker模板应用
- Android开发在路上:少去踩坑,多走捷径