五週第五次課(9月1日)
8.10 shell特殊符號cut命令
8.11 sort_wc_uniq命令
8.12 tee_tr_split命令
8.13 shell特殊符號下
相關測驗題目:http://ask.apelearn.com/question/5437
8.10 shell特殊符號cut命令
cut -d "指定分隔符" -f1,2 截取第幾段
8.11 sort_wc_uniq命令
sort排序 默認按照ASII碼排序。
sort -n以數字排序。字母和特殊符號被認爲是0,所以會排在前面
sort -rn 反序
sort -t可以指定分隔符,可以指定走那段分割來排序。
wc -l統計行數
wc -m統計字符數,結尾換行符也會被計入在內
wc -w統計詞的個數。
uniq去重複的。一般要和sort結合起來用
sort -n | uniq
8.12 tee_tr_split命令
sort 1.txt | uniq -c | tee a.txt
把輸出的內容輸出到a.txt,並且把結果打印到屏幕上。!!!
sort 1.txt | uniq -c | tee -a a.txt
tee -a表示追加。
tr命令
echo "NiHao" | tr 'H' 'h'
echo "NiHao" | tr '[a-z]' '[A-Z]'
split 切割
-b
-l 行
8.13 shell特殊符號下
多條命令寫在一行,用分號分割。
&> 錯誤和正確全部重定向到一個文件中
&& 前面的命令成功纔會執行後面的命令