make 2>&1
Background of this post: Recently, I always noticed that many guys can't distinguish the meaning among stdin, stdout, and stderr, especially, they always ask the same question as: what does 21 exactly mean? So, here I want to give a summar
Background of this post:
Recently, I always noticed that many guys can't distinguish the meaning among stdin, stdout, and stderr, especially, they always ask the same question as: what does "2>&1" exactly mean?
So, here I want to give a summary of this three things, and of course, I'd like to take this "2>&1" as an example.
-----------------------
Interpretation:
First of all, I want to give out the exact meaning of "2>&1":
2>&1:
0 is stdin. 1 is stdout. 2 is stderr
-------------
There's one way to remember this construct (maybe it is not entirely accurate):
-------------
First of all, 2>1 looks like a very good way to redirect stderr to stdout. but remember, it has a very harmful disadvantage: it may 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.
-------------
>& is shell syntax for "fold a file descriptor into another", you can also interprete it as "it is the syntax to redirect a stream to another file descriptor"
So, now, have you got the meaning of what does "2>&1" exact mean? I think you do!
Yes, it's very easy to understand, but what's more, I want to go little deep into this topic.
-----------------------
Furthermore:
Following picture gives a very clear defination of what is stdin stdout and stderr:
# In Linux everything is a file.
# Your hardware is also a file:
* 0 - Input - Keyboard (stdin)
* 1 - Output - Screen (stdout)
* 2 - Error - Screen (stderr)
#
For standard output:
Clear
enough?
If you still feel confused about this, you can view this page to find more infomation:
http://tldp.org/LDP/abs/html/io-redirection.html
-----------------------
Example:
Finally, I want to give you a example to end this entry(Try to understand it ^_^):
The output of a.out is the following, without the 'STDXXX: ' prefix.
STDERR: stderr output<br> STDOUT: more regular
./a.out 3>&1 1>&2 2>&3 3>&- | sed 's/e/E/g'<br> more regular<br> stderr output
- First save stdout as &3 (&1 is duped into 3).
- Next send stdout to stderr (&2 is duped into 1).
- Send stderr to &3 (stdout) (&3 is duped into 2).
- close &3 (&- is duped into 3)
-----------------------
Others:
If you want to know what's the difference between "cmd >file 2>&1" and "cmd >file 2>file", pls refer this post which written by r2007:
http://bbs.chinaunix.net/thread-764727-1-1.html

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

如何使用CSS实现元素的旋转背景图动画效果背景图动画效果可以增加网页的视觉吸引力和用户体验。本文将介绍如何使用CSS实现元素的旋转背景图动画效果,并提供具体的代码示例。首先,我们需要准备一张背景图,可以是任何你喜欢的图片,例如一张太阳或者电风扇的图片。将该图片保存并命名为“bg.png”。接下来,创建一个HTML文件,并在文件中添加一个div元素,将其设置为

linux make命令是系统管理员和程序员用的最频繁的命令之一,也是指一个“自动编译管理器”,其中“自动”是指它能够根据文件时间戳自动发现跟新过的文件而减少工作量,同时,他能通过读入makefile文件的内容来执行大量编译工作。

对于PHP开发者来说,使用POST带参数跳转页面是一项基本技能。POST是HTTP中一种发送数据的方法,它可以通过HTTP请求向服务器提交数据,跳转页面则是在服务器端进行页面的处理和跳转。在实际开发中,我们经常需要使用POST带参数来跳转页面,以达到一定的功能目的。

PHP是一种广泛使用的服务器端脚本语言,它可以用于创建交互式和动态的Web应用程序。在开发PHP应用时,我们通常需要通过表单将用户输入数据提交给服务器端处理。然而,有时候我们需要在PHP中判断是否有表单数据被提交,这篇文章将介绍如何进行这样的判断。

python模拟浏览器发送post请求importrequests格式request.postrequest.post(url,data,json,kwargs)#post请求格式request.get(url,params,kwargs)#对比get请求发送post请求传参分为表单(x-www-form-urlencoded)json(application/json)data参数支持字典格式和字符串格式,字典格式用json.dumps()方法把data转换为合法的json格式字符串次方法需要

一、java调用post接口1、使用URLConnection或者HttpURLConnectionjava自带的,无需下载其他jar包URLConnection方式调用,如果接口响应码被服务端修改则无法接收到返回报文,只能当响应码正确时才能接收到返回publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

实现如下:server{listen80;listen443ssl;server_namenirvana.test-a.gogen;ssl_certificate/etc/nginx/ssl/nirvana.test-a.gogen.crt;ssl_certificate_key/etc/nginx/ssl/nirvana.test-a.gogen.key;proxy_connect_timeout600;proxy_read_timeout600;proxy_send_timeout600;c

make如何工作的对于不知道背后机理的人来说,make命令像命令行参数一样接收目标。这些目标通常存放在以“makefile”来命名的特殊文件中,同时文件也包含与目标相对应的操作。更多信息,阅读关于makefiles如何工作的系列文章。当make命令第一次执行时,它扫描makefile找到目标以及其依赖。如果这些依赖自身也是目标,继续为这些依赖扫描makefile建立其依赖关系,然后编译它们。一旦主依赖编译之后,然后就编译主目标(这是通过make命令传入的)。现在,假设你对某个源文件进行了修改,你
