這是在 IBM developerWorks 的文章,列出了 10 個在 *NIX 下良好的使用習慣,其中有些也有犯下。以下是作者的10 個建議,並加上簡單中文簡介:
1. Make directory trees in a single swipe.
可以在用 mkdir 時加上 -p 選項,就可以遞迴建立目錄。
2. Change the path; do not move the archive.
在 tar 指令加上 -C 選項,指令解壓的目的地,不需把壓縮檔移動。
3. Combine your commands with control operators.
用 control operators 合拼指令,例如 ";", "&&" 及 "||"。
4. Quote variables with caution.
用雙引號括起變數。
5. Use escape sequences to manage long input.
用 escape sequences 處理較長的指令輸入。
6. Group your commands together in a list.
group 起一組指令。
7. Use xargs outside of find.
用 xargs 過濾從 find 得出的結果。
8. Know when grep should do the counting -- and when it should step aside.
grep 可以加上 -c 選項計算結果總數,不用透過 pipe 執行 wc。
9. Match certain fields in output, not just lines.
可以用類似 awk 這些工具配合 grep 使用,傳回指定欄位,不是一整行結果。
10. Stop piping cats.
不要用 cat 透過 pipe 報行 grep 搜索檔案,改用 grep 直接執行。
以上中文解釋可能寫得不好,詳細內容可參考原文: Learn 10 good UNIX usage habits