linux shell 命令

来源:互联网 发布:淘宝答题抢红包 编辑:程序博客网 时间:2024/06/03 16:28

在学习PostgreSQL时,有下面一个命令:

$ postgres -D /usr/local/pgsql/data >logfile 2>&1 &

文件描述符1表示标准输出
文件描述符2表述标准错误

File descriptor 1 is the standard output (stdout).
File descriptor 2 is the standard error (stderr).

Here is one way to remember this construct (although it is not entirely accurate): at first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as “redirect stderr to a file named 1”. & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1.

参考:
https://stackoverflow.com/questions/818255/in-the-shell-what-does-21-mean

| 是管道符号 表示前面的命令结果作为后面的命令输入
这里写图片描述

管道命令(pipe)的详细介绍
linux shell 管道命令(pipe)使用及与shell重定向区别

0 0