查看文件內容
- cat(concatenate) 連續顯示文件內容
cat [-AbEnTv]
-A 顯示特殊字符,相當於-ETv
-b 顯示行號,空白行不顯示
-E 顯示斷行字符$
-n 顯示行號,空白行也顯示
-T 顯示tab爲^I
-v 顯示特殊字符
e.g.:
cat -n test.txt
1 cross every river
2
3 can you hear me I'm calling
4 can you hear me I say
5
6 I would cross every river
7 I would sail every sea
8
9 I would climb every mountain
10 If it would bring you back to me
cat -n test.txt
1 cross every river
2
3 can you hear me I'm calling
4 can you hear me I say
5
6 I would cross every river
7 I would sail every sea
8
9 I would climb every mountain
10 If it would bring you back to me
- tac 反向連續顯示文件內容
tac test.txt
If it would bring you back to me
I would climb every mountain
I would sail every sea
I would cross every river
can you hear me I say
can you hear me I'm calling
cross every river
- nl 添加行號打印
nl [-bnw] 文件
----------
-b :指定行號顯示的方式
-b a 顯示行號,空行也不例外
-b t 顯示行號,空行不顯示
-n :指定顯示行號的方式
-n ln 顯示在屏幕的最左邊
-n rn 顯示在屏幕的最右邊,不加零
-n rz 顯示在屏幕的最右邊,加零
-w :指定行號字段佔的位數
可翻頁查看文件內容
- more 按頁顯示
more [-dlfpcsu] [-num] [+/pattern] [+linenum] [file ...]
--------------------
-d 提示用戶"[Press space to continue, 'q' to quit.]",當用戶按下非法按鍵時,提示"[Press 'h' for instructions.]"
-p 清空屏幕顯示
____________________
命令:
h或?顯示命令
空格:向下翻頁
enter:向下翻滾動一行
= :顯示當前行號
/patten :搜索
b:向前翻頁
q:退出
:f :顯示當前文件名和行號
:n :去後面第K個文件,默認爲1
:p :去前面第k個文件,默認爲1
- less 按頁顯示,無需一次性讀取整個文件,速度較快
less比more更加靈活
顯示文件頭尾(head、tail)
- head 顯示頭幾行
head [-n number]文件
————————————————————————————————————
參數解釋
-n 接數字代表行數,number 爲負時,顯示前(總行數-number)行
- tail 顯示結尾幾行
tail [-n number] 文件
number表示顯示行數
——————————————————————————————————————
參數解釋
-n 接數字代表行數,
*tail -n +20 文件名 //顯示後(總行數-20)行
-f 表示持續監測後面所接的文件,知道ctl-c才結束 //文件更改時,會及時顯示在屏幕上
顯示非純文本文檔
- od
od [-t type]文件
———————————————
參數解釋
-t : 解各種類型
a 默認字符輸出
c ASCII字符輸出
d 十進制(decimal)輸出數據
f 利用浮點數來輸出數據
o 利用八進制輸出數據
x 利用十六進制輸出數據
修改文件時間戳
- touch 修改文件時間戳
linux下記錄的文件時間
- modification time (mtime) 文件內容修改時,會更新該時間
- status time (ctime) 文件狀態改變時會更新該時間,如權限和屬性
- access time (atime) 文件內容被讀取時會更新該時間。
touch [-acdmt] 文件
__________________
參數解釋
-a 僅修改access time
-c 不創建新文件
-d 接欲修訂的日期,也可使用--date=“日期或時間”
-m 僅修改mtime
-t 接欲修訂的時間