»

Redirect in BASH

Log — Tags: — Posted by Starck on June 23, 2013


# 執行 command, 標準輸出結果轉到 correct.txt, 錯誤輸出結果轉到到 error.txt
$ [command] 1> correct.txt 2> error.txt

要讓錯誤輸出結果不顯示, 可以利用/dev/null:

$ [command] 1> result.txt 2> /dev/null



example:

# 顯示 gem 的規格, 如果沒有這個 gem 則不顯示任何訊息
$ gem spec [gem name] 2>/dev/null
# gem spec zurb-foundation 2>/dev/null

(c) 2018 Starck Lin | powered by WordPress