Unix 基本指令操作

IO Redirection: File Descriptors
file descriptor 0 is associated with STDIN, 1 with STDOUT, and 2 with STDERR.
ex: 2>&1 將 錯誤訊息(STDERR) 直接導向 標準輸出(STDOUT)
ex: 2>& > /tmp/output
ex: >& > /tmp/output (標準輸出 輸入都一起導到 /tmp/output file)

< input file : read standard input from file
> output file : write standard output to file
>> output file: append standard output to file
>& error file : write error message to file
| command2 : pipe output as input for command2

ex: ls 2>/dev/null 1>/tmp/output
& => 指定到 &1 的變數(不然會變成 1 的 file)

其它兩個很常用的程式.

find
-name '*stuff*'
-mtime +5 : find files modified name then 5 days.
-mtime -5 : find files modified less then 5 days ago.
-size +1024c: find files bigger then 1k bytes.
-print: find full filenames meeting previous criteria.
-ls : find file name and other information.
-exec rm {} ; : Remove the file meeting previous criteria.

diff
-b: ignore Blank Spaces
-c: show more of the content.

作者: Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.

在〈Unix 基本指令操作〉中有 2 則留言

JOY 發表迴響取消回覆

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料