一、查看文件—–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:退出