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脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

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

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

如何使用CSS實現元素的旋轉背景圖動畫效果背景圖動畫效果可以增加網頁的視覺吸引力和使用者體驗。本文將介紹如何使用CSS實現元素的旋轉背景圖動畫效果,並提供具體的程式碼範例。首先,我們需要準備一張背景圖,可以是任何你喜歡的圖片,例如一張太陽或電風扇的圖片。將該圖片儲存並命名為“bg.png”。接下來,建立一個HTML文件,並在文件中新增一個div元素,將其設定為

linux make命令是系統管理員和程式設計師用的最頻繁的命令之一,也是指一個“自動編譯管理器”,其中“自動”是指它能夠根據文件時間戳自動發現跟新過的文件而減少工作量,同時,他能透過讀入makefile檔案的內容來執行大量編譯工作。

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格式字串次方法需要

對於PHP開發者來說,使用POST帶參數跳轉頁面是一項基本技能。 POST是HTTP中一種發送資料的方法,它可以透過HTTP請求向伺服器提交數據,跳轉頁面則是在伺服器端進行頁面的處理和跳轉。在實際開發中,我們經常需要使用POST帶參數來跳轉頁面,以達到一定的功能目的。

一、java調用post介面1、使用URLConnection或HttpURLConnectionjava自帶的,無需下載其他jar包URLConnection方式調用,如果介面回應碼被服務端修改則無法接收到返回報文,只能當回應碼正確時才能接收到回傳publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

PHP是一種廣泛使用的伺服器端腳本語言,它可以用於建立互動式和動態的網路應用程式。在開發PHP應用程式時,我們通常需要透過表單將使用者輸入資料提交給伺服器端處理。然而,有時候我們需要在PHP中判斷是否有表單資料被提交,這篇文章將介紹如何進行這樣的判斷。

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

PHP是一種廣泛應用於網站開發的程式語言,而頁面跳躍並攜帶POST資料是在網站開發中常見的需求。本文將介紹如何實現PHP頁面跳轉並攜帶POST數據,包括具體的程式碼範例。在PHP中,頁面跳躍一般透過header函數實現。如果需要在跳轉過程中攜帶POST數據,可以透過以下步驟完成:首先,建立一個包含表單的頁面,使用者在該頁面填寫資訊並點擊提交按鈕。在表單的acti
