星期六, 九月 10, 2005

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.

相關標籤
Add this page to del.icio.us Add this page to Yahoo Taiwan's bookmark Add this page to MyShare

發表迴響

標題

內容 (限制 1000 字)

暱稱

電子郵件

個人網頁


 authimage


PS: 若無法留言, 請先確認是否有打開 JavaScript, 造成您的困擾, 實在萬分對不起 Orz...(如果無法留言, 勞煩可以發信給我好嗎? 謝謝.)
PS2: 若您的留言被誤判, 我都會再自行看過, 不需要一直重覆張貼~