> outfile 2>&1 與 2>&1 > outfile
這篇文章來簡單地說明一下這兩種寫法的區別
首先2>&1
的意思是將描述符2
重定向至描述符1
現在我們在/test
目錄下有一個檔案test
,內容為test!!!
我們執行如下兩條命令
cat /test/test > outfile 2>&1
cat /test/test 2>&1 > outfile
兩條命令的輸出均被重定向到了outfile
檔案中
但是如果我們把test
替換成一個不存在的檔案nofile
時,這兩條命令的執行結果就不一樣了
cat /test/test > outfile 2>&1
,這條命令沒有任何顯式輸出,因為shell
outfile
檔案中,然後標準錯誤
被定向到標準輸出
,也就是說,標準出錯
被重定向到outfile
中
我們檢視outfile
檔案的內容:
[email protected]:/test# cat outfile
cat: /test/nofile: No such file or directory
錯誤資訊被輸出到了nofile
中
現在執行cat /test/nofile 2>&1 > outfile
,結果是錯誤資訊被輸出到了螢幕
,這是因為標準出錯
被重定向到標準輸出
,然後標準輸出
才被定向到outfile
檔案,因此我們就在螢幕上看到了出錯資訊,而且outfile
相關推薦
> outfile 2>&1 與 2>&1 > outfile
這篇文章來簡單地說明一下這兩種寫法的區別 首先2>&1的意思是將描述符2重定向至描述符1 現在我們在/test目錄下有一個檔案test,內容為test!!! 我們執行如下兩條命令 cat /test/test > outfile 2>&1 c
Shell中的>/dev/null 2>&1 與 2>&1 >/dev/null 與&>/dev/null 的區別
文件描述符 art 應該 tar 輸入 情況 style 鍵盤 blog 默認情況下,總是有三個文件處於打開狀態,標準輸入(鍵盤輸入)、標準輸出(輸出到屏幕)、標準錯誤(也是輸出到屏幕),它們分別對應的文件描述符是0,1,2 。那麽我們來看看下面的幾種重定向方法的區別: &
Leetcode717.1-bit and 2-bit Characters1位元與2位元字元
有兩種特殊字元。第一種字元可以用一位元0來表示。第二種字元可以用兩位元(10 或 11)來表示。 現給一個由若干位元組成的字串。問最後一個字元是否必定為一個一位元字元。給定的字串總是由0結束。 示例 1: 輸入: bits = [1, 0, 0] 輸出:
BASH中2>1 與2>&1的區別
在寫BASH指令碼時經常看到2>1 和2>&1的寫法,經常分不清楚有什麼區別.兩種寫法都可以工作,但差別還是很大的 2>1的作用是把標準錯誤的輸出重定向到1,但這個1不是標準輸出,而是一個檔案!!!,檔名就是1 2>&1的作用是把標
Shell中的>/dev/null 2>&1 與 2>&1 >/dev/null 與&>/dev/null 的區別
預設情況下,總是有三個檔案處於開啟狀態,標準輸入(鍵盤輸入)、標準輸出(輸出到螢幕)、標準錯誤(也是輸出到螢幕),它們分別對應的檔案描述符是0,1,2 。那麼我們來看看下面的幾種重定向方法的區別: >/dev/null 2>&1 // 實際上,應該等
Shell的>/dev/null、2>&1、2>1
重新 test lan tdi 就是 顯示 tran mouse flat 轉載自:http://dos2unix.cn/link/480 1. 標準輸入stdin文件描述符為0,標準輸出stdout文件描述符為1,標準錯誤stderr文件描述符為2 2. /dev
javaSE之面向物件程式設計->類與物件(上)——1 and 2
一、面向物件程式設計的簡介 在C語言的學習中我們所有的程式風格都是面向過程的,也就是比如兩個數相加這個程式段需要多次執行那麼我們在C語言中只能通過程式碼的賦值貼上才可以辦到,但是我們在面向過程程式設計裡面也有這樣類似的思想,就是函式。在java中我們採用面向物件的方法,就是可以將程式碼的可重
Python的線程&進程&協程[2] -> 進程 -> 多進程的基本使用
程序 參數 .html shell 測試 求一個 輸入 cti hello 多進程的基本使用 1 subprocess 常用函數示例 首先定義一個子進程調用的程序,用於打印一個輸出語句,並獲取命令行參數 1 import sys 2 print(‘Called_Fu
Python與數據結構[0] -> 鏈表[2] -> 鏈表有環與鏈表相交判斷的 Python 實現
lis 退出 測試 htm 判斷鏈表是否有環 += 帶環鏈表 off long 鏈表有環與鏈表相交判斷的 Python 實現 目錄 有環鏈表 相交鏈表 1 有環鏈表 判斷鏈表是否有環可以參考鏈接, 有環鏈表主要包括以下幾個問題(C語言描述): 判斷環是否存在:
【共讀Primer】8.<2.1> 基本內置類型(2) Page32
強類型 聲明 要去 單引號 prime 無限循環 無符號 編譯運行 bsp 雖然C++中的類型是強制聲明的,但是這並不意味著不同類型之間不可以進行一些計算或賦值。 我們來看下面的一組代碼 1 #include <iostream> 2 3 int ma
Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) F - Uniformly Branched Trees 無根樹->有根樹+dp
color nbsp ORC for ans print test include make F - Uniformly Branched Trees #include<bits/stdc++.h> #define LL long long #defi
常見位操作及運算應用舉例:1,C語言中位運算子異或“∧”的作用2,異或運算的作用3,&(與運算)、|(或運算)、^(異或運算)
1 C語言中位運算子異或“∧”的作用: 異或運算子∧也稱XOR運算子。它的規則是若參加運算的兩個二進位同號,則結果為0(假);異號則為1(真)。即0∧0=0,0∧1=1,1∧1=0。如: 即071∧052,結果為023(八進位制數)。 “異或”的意思是判斷兩個相應的位值是否為“
菜鷄日記——《彙編與介面技術》第1章 基礎知識 & 第2章 80X86計算機結構
第1章 基礎知識 第2章 80X86計算機結構 (以16位的8086計算機為教學物件) Intel 8086 CPU: 累加器:用於算術、邏輯運算以及與外設傳送資訊等。 基址暫存器:常於
錯誤:libatk1.0-0 : Depends: libatk1.0-data (>= 2.30.0-1) but 2.28.1-1 is to be installed
在Ubuntu下安裝檔案時遇到以下錯誤: The following packages have unmet dependencies: libatk1.0-0 : Depends: libatk1.0-data (>= 2.30.0-1) but 2.28.1-1 is t
一:1.2【print&input與變量和運算符】
直接 字符串 dvd 16px 答案 定義變量 元組 程序 文件名 【路徑】 絕對路徑:從根目錄開始鏈接的路徑 --->cd C:\Windows\Boot\DVD\EFI\en-US 相對路徑:不從根目錄開始鏈接的路徑 ----> cd Boot\DVD
CTR學習筆記&程式碼實現2-深度ctr模型 MLP->Wide&Deep
## 背景 這一篇我們從基礎的深度ctr模型談起。我很喜歡Wide&Deep的框架感覺之後很多改進都可以納入這個框架中。Wide負責樣本中出現的頻繁項挖掘,Deep負責樣本中未出現的特徵泛化。而後續的改進要麼用不同的IFC讓Deep更有效的提取特徵互動資訊,要麼是讓Wide更好的記憶樣本資訊 ##
1.4.2 暫停與恢復Activity
devel 過程 信號 fun ide 然而 -a 動作 好的 在正常使用app時,前端的activity有時會被其他可見的組件阻塞(obstructed),從而導致當前的activity進入Pause狀態。例如,當打開一個半透明的activity時(例如以對話框的形式),
&lt;C#入門經典&gt;學習筆記1之初識C#
ack fad 浮點 2.0 十六進制 float 一個 sca 每一個 序言 選擇《 C#入門經典第五版》作為自學書籍,以此記錄學習過程中的筆記與心得。 C#簡單介紹 1. C#是一種塊結構的語言 2. C#區分大寫
<<深入分析javaWeb技術內幕>>讀書筆記-JVM內存管理2
空間 不同 class logs 減少 src 一次 ges jvm垃圾回收 JVM垃圾回收策略 1.靜態內存分配和回收 編譯時已經確定了內存空間大小,程序被加載後則一次性分配好內存空間.程序結束後,則對應棧幀撤銷,分配的靜態內存空間則被回收. 2.動態內存分配和回收
Unity Shaders and Effects Cookbook (4-1)(4-2)靜態立方體貼圖的創建與使用
sampler lba into 現實生活 rate valid ase pro 執行 開始學習第4章 - 著色器的反射看完了1、2節,來記錄一下。反射主要是利用了 Cubemap 立方體貼圖。認識Cubemap立方體貼圖。就如同名字所說。在一個立方體上有6張圖。就這樣