more与less,head,tail,od(非纯文本档查看)

more(一页一页翻动,不能往前翻)

  • 空格键 (space):代表向下翻一页;
  • Enter :代表向下翻『一行』
  • /字符串 :代表在这个显示的内容当中,向下搜寻『字符串』这个关键词;
  • f :立刻显示出文件名以及目前显示的行数;
  • q :代表立刻离开 more ,不再显示该文件内容。
  • b 或 [ctrl]-b :代表往回翻页,不过这动作只对文件有用,对管线无用。
[root@study ~]# more /etc/man_db.conf
#
#
# This file is used by the man-db package to configure the man and cat paths.
# It is also used to provide a manpath for those without one by examining
# their PATH environment variable. For details see the manpath(5) man page.
#
.....(中间省略).....
--More--(28%)  <== 重点在这一行喔!你的光标也会在这里等待你的指令

less

  • 空格键
  • [pagedown]:向下翻动一页;
  • [pageup] :向上翻动一页;
  • /字符串 :向下搜寻『字符串』的功能;
  • ?字符串 :向上搜寻『字符串』的功能;
  • n :重复前一个搜寻 (与 / 或 ? 有关!)
  • N :反向的重复前一个搜寻 (与 / 或 ? 有关!)
  • g :前进到这个资料的第一行去;
  • G :前进到这个数据的最后一行去 (注意大小写);
  • q :离开 less 这个程序;
[root@study ~]# less /etc/man_db.conf
#
#
# This file is used by the man-db package to configure the man and cat paths.
# It is also used to provide a manpath for those without one by examining
# their PATH environment variable. For details see the manpath(5) man page.
#
.....(中间省略).....
:    <== 这里可以等待你输入指令!

head (取出前面几行)

默认的情况中,显示前面十行

[root@study ~]# head [-n number] 文件
选项与参数:
-n	:后面接数字,代表显示几行的意思
[root@study ~]# head /etc/man_db.conf
# 默认的情况中,显示前面十行!若要显示前 20 行,就得要这样:
[root@study ~]# head -n 20 /etc/man_db.conf
范例:如果后面 100 行的数据都不打印,只打印/etc/man_db.conf 的前面几行,该如何是好?
[root@study ~]# head -n -100 /etc/man_db.conf

tail (取出后面几行)

默认的情况中,显示最后的十行

[root@study ~]# tail [-n number] 文件
选项与参数:
-n :后面接数字,代表显示几行的意思
-f :表示持续侦测后面所接的档名,要等到按下[ctrl]-c 才会结束 tail 的侦测
[root@study ~]# tail /etc/man_db.conf
# 默认的情况中,显示最后的十行!若要显示最后的 20 行,就得要这样:
[root@study ~]# tail -n 20 /etc/man_db.conf
范例一:如果不知道/etc/man_db.conf 有几行,却只想列出 100 行以后的数据时?
[root@study ~]# tail -n +100 /etc/man_db.conf
范例二:持续侦测/var/log/messages 的内容
[root@study ~]# tail -f /var/log/messages
<==要等到输入[crtl]-c 之后才会离开 tail 这个指令的侦测!

od

[root@study ~]# od [-t TYPE] 文件
选项或参数:
-t			:后面可以接各种『类型 (TYPE)』的输出,例如:
a 			:利用默认的字符来输出;
c 			:使用 ASCII 字符来输出
d[size] 	:利用十进制(decimal)来输出数据,每个整数占用 size bytes ;
f[size] 	:利用浮点数(floating)来输出数据,每个数占用 size bytes ;
o[size] 	:利用八进制(octal)来输出数据,每个整数占用 size bytes ;
x[size] 	:利用十六进制(hexadecimal)来输出数据,每个整数占用 size bytes ;


范例一:请将/usr/bin/passwd 的内容使用 ASCII 方式来展现!
[root@study ~]# od -t c /usr/bin/passwd
0000000 177 E L
0000020 003 \0 >
0000040 @ \0 0000060 \0 0000100 006
F 002 001 001
\0
\0 \0 \0 \0 \0 \0 \0 \0
\0 001 \0 \0 \0 364 3 \0 \0 \0 \0 \0 \0
\0 \0 \0 \0 \0 \0 x e \0 \0 \0 \0 \0 \0
\0 \0 \0 @ \0 8 \0 \t \0 @ \0 035 \0 034 \0
\0 \0 \0 005 \0 \0 \0 @ \0 \0 \0 \0 \0\0\0
.....(后面省略)....
# 最左边第一栏是以 8 进位来表示 bytes 数。以上面范例来说,第二栏 0000020 代表开头是
# 第 16 个 byes (2x8) 的内容之意。





范例二:请将/etc/issue 这个文件的内容以 8 进位列出储存值与 ASCII 的对照表
[root@study ~]# od -t oCc /etc/issue
0000000 134 123 012 113 145 162 156 145 154 040 134 162 040 157 156 040
\
S
\n
K
e
r
n
0000020 141 156 040 134 155 012 012
a
0000027
n
\
m
\n
\n
e
l
\
r
o
n# 如上所示,可以发现每个字符可以对应到的数值为何!要注意的是,该数值是 8 进位喔!

鸟哥私房菜中的“od -t oCc /etc/issue”的意思

猜你喜欢

转载自blog.csdn.net/qq_52835624/article/details/118383847