第七章 Seeing The World As The Shell Sees It
- echo --- Display a line of text 顯示一列文字
- 延展路徑名稱Pathname Expansion --- 萬用字元的運作
echo * --- 列出目錄內的所有檔案 (不會顯示隱藏檔案)
echo .* --- 顯示隱藏檔案
- 延展波浪Tilde Expansion
echo ~ --- 回至家目錄
- 延展算術Arithmetic Expansion
echo $((4+4)) --- 運算數式
- 延展大括弧Brace Expansion --- 依大括弧內的模式,延展成多個字串
echo {Z..A} --- 倒序排列字母
新增檔案或目錄之用
- 延展參數Parameter Expansion --- 把一小段資料以客製的名稱儲存起來,或許可以將這些資料稱為變數,"USER" 變數的內容就是使用者名稱
echo $USER --- 顯示現在的使用者名稱
- 替代命令Command Substitution
echo $(ls)
ls -l $(which cp) --- 當做ls命令的參數,還可用管線
- 引號 Quoting
echo this is a test --- shell移除額外的空格
echo The total is $100.00 --- shell看不懂參數"$1",直接移除它
echo "$USER $((2+2)) $(cal)" --- 顯示使用者當下系統的當月日曆
echo $(cal) --- 產生多個參數
echo "$(cal)" --- 只有一個參數
第八章Advanced Keyboard Tricks
- clear --- Clear the screen清除螢幕
- history --- Display the contents of the history list顯示記錄清單的內容
history | grep /usr/bin --- 查看使用/usr/bin的命令