一、顯示命令
cat | more | less | head | tail | sort | uniq | file | locate | which |
二、使用
1.cat
描述:查看文件內容
用法:cat 文件1 文件2
參數:無
案例:
2.more
描述:翻頁查看文件內容
用法:more 文件名
3.less
描述:翻頁查看文件內容(more的加強版)
用法:less 文件名
4.head
描述:顯示文件內容
用法:head [參數] 文件
參數:
-n num 顯示文件前num行
-c num 顯示文件前n個字符
案例:
5.tail
描述: 顯示文件內容
用法:tail [參數] 文件
參數:
-n num 顯示文件的最後num行
-c num 顯示文件的最後num個字符
案例:
6.sort
描述:將文件中的內容排序輸出
用法:sort [參數] 文件
參數:
-r 反序輸出
-o filename 將文件排序內容輸出到指定文件
案例:
7.uniq
描述:比較相鄰兩行,如果相同,則不再重複顯示
用法:uniq 文件名
8.file
描述:顯示文件或目錄的類型
用法:file 文件名或目錄
案例:
9.locate
描述:查找絕對路徑中包含指定字符串的文件
用法:locate 字符串
案例:
10.which
描述:確定程序的具體位置
用法:which 命令
案例: