一、查看文件-----cat (詳情參考:http://blog.sina.com.cn/s/blog_52f6ead0010127xm.html)
語法結構: cat 查看方式 文件
cat? -A? ?:? show all 顯示所有內容,相當于-vET
?
[root@localhost tmp]# cat -A /etc/profile #注釋:查看/erx/目錄下profile文件的內容
cat -b :對非空白行驚醒編號
?
[root@localhost tmp]# cat -b /etc/profile 注釋:注:查看/etc/目錄下的profile內容,并且對非空白行進行編號,行號從1開始;
?
cat -E :show end在每行結束的位置顯示$
?
[root@localhost tmp]# cat -E^C/etc/profile #注:查看/etc/下的profile內容,并且在每行的結尾處附加$符號
cat -n
?
[root@localhost tmp]# cat -n /etc/profile #注釋:注:對/etc目錄中的profile的所有的行(包括空白行)進行編號輸出顯示;
cat -T 將tab顯示為^T
cat -v :列出一些看不來的特殊字符
?
二、文件查看-----nl命令
文件文字為text.txt,作為測試文件
?
for i in range(10):print("大傻瓜")list=[1,2,3,4,5,6,7,8] for i in list:print(i)ok! list=[1,2,3,4,5,6,7,8] for i in list:print(i)ok!
1、 -b 模式下的操作:(是否顯示空白行的行號)
-b? a:表示不論是否有空行,也同樣列出行號
?
[root@localhost a]# nl -b a text #顯示包括空白行的行數1 for i in range(10):2 print("大傻瓜")3 4 5 6 list=[1,2,3,4,5,6,7,8]7 for i in list:8 print(i)9 10 11 12 ok!13 list=[1,2,3,4,5,6,7,8]14 for i in list:15 print(i)16 17 18 19 ok!20 21 22
-b? t:不現實空白的行數,計算中跳過空白行
?
[root@localhost a]# nl -b t text #顯示有效行數1 for i in range(10):# 2 print("大傻瓜")3 list=[1,2,3,4,5,6,7,8]4 for i in list:5 print(i)6 ok!7 list=[1,2,3,4,5,6,7,8]8 for i in list:9 print(i)10 ok!
2、-n模式:
?
-n ln? :行號顯示在屏幕的最左側
[root@localhost a]# nl -n ln text#行號顯示在左邊 1 for i in range(10): 2 print("大傻瓜")3 list=[1,2,3,4,5,6,7,8] 4 for i in list: 5 print(i)6 ok! 7 list=[1,2,3,4,5,6,7,8] 8 for i in list: 9 print(i)10 ok!
-n rn? :行號顯示在屏幕的最右側
?
[root@localhost a]# nl -n rn text #顯示在屏幕的最右側1 for i in range(10):2 print("大傻瓜")3 list=[1,2,3,4,5,6,7,8]4 for i in list:5 print(i)6 ok!7 list=[1,2,3,4,5,6,7,8]8 for i in list:9 print(i)
-n rz? :行號顯示在屏幕的最右側,前面加0
000001 for i in range(10): 000002 print("大傻瓜")000003 list=[1,2,3,4,5,6,7,8] 000004 for i in list: 000005 print(i)000006 ok! 000007 list=[1,2,3,4,5,6,7,8] 000008 for i in list: 000009 print(i)000010 ok!
?
3、-w模式:縮進多少位
[root@localhost a]# nl -w 40 text 1 for i in range(10):2 print("大傻瓜")3 list=[1,2,3,4,5,6,7,8]4 for i in list:5 print(i)6 ok!7 list=[1,2,3,4,5,6,7,8]8 for i in list:9 print(i)10 ok!
?
三、查看文件操作-----more(一頁一頁翻動)
格式: more 【文件】
1、空格:向下翻一頁
2、回車:向下翻一行
3、“/” :搜索
4、:f :立刻顯示文件名和行數
5、b:翻到第一頁
6、q:離開
?
四、查看文件------less(一頁一頁翻動)
? 1、空格:向下翻一頁
2、pagedown:下一頁
2、pageup:上一頁
4、n:重復前一個搜索
5、N:反方向反復前一個搜索
6、q:退出
?
?
? ?