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.
請問如何使用ls列出單一user或group的檔案?
搭配 grep 來做應該比較簡單.