cat 由第一行開始連續 (concatenate) 顯示檔案內容。
tac 由最後一行開始連續顯示檔案內容。
more 一頁一頁的顯示檔案內容。
less 有 more 的功能且可以往前翻頁。
head 只看頭幾行。
tail 只看最後幾行。
nl 顯示時亦輸出行號。
od 以二進位的方式顯示檔案內容。
[root@dywHome2 test]# cat [-nETvtA] NAME
參數說明:
-n: 列出行號。
-E: 行尾列出符號 $ 。
-T: TAB 以符號 ^I 列出。
-v: 列出非列印字元,除 TAB 與 LFD,例如 DOS 檔案的斷行符號。
-t: 同 -vT。
-A: 同 -vET。
#範例:
[root@dywHome2 test]# cat foo
This is a test file for cat.
OK! everything is OK.
[root@dywHome2 test]# cat -n foo
1 This is a test file for cat.
2 OK! everything is OK.
[root@dywHome2 test]# cat -E foo
This is a test file for cat.$
OK! everything is OK.$
[root@dywHome2 test]# cat -T foo
This is a test file for cat.
OK!^Ieverything is OK.
[root@dywHome2 test]# cat -nA foo
1 This is a test file for cat.$
2 OK!^Ieverything is OK.$
[root@dywHome2 test]# tac filename
#範例:
[root@dywHome2 test]# tac foo
OK! everything is OK.
This is a test file for cat.
[root@dywHome2 test]# more filename
#範例:
[root@dywHome2 test]# more /etc/inittab
#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
# Default runlevel. The runlevels used by Mandriva Linux are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
[root@dywHome2 test]# ls -al ~ | more
[root @test /root ]# less NAME
#範例:
[root@dywHome2 test]# less /etc/man.config
# /word 搜尋字串 word, n 繼續向下搜尋。
# q 離開。
[root @test /root]# head [-n number] [檔名]
參數說明:
-n :顯示 number 行
#範例:
[root @test /root]# head ~/.bashrc %*<==預設情況下,顯示頭十行 *)
[root @test /root]# head -n 20 ~/.bashrc%*<==顯示頭二十行!*)
[root @test /root ]# tail [-n number] [檔名]
參數說明:
-n :顯示 number 行
#範例:
[root @test /root]# tail ~/.bashrc
[root @test /root]# tail -n 5 ~/.bashrc %*<==只顯示最後面五行!*)
[root @test /root]# head –n 20 ~/.bashrc | tail –n 10 %*<==顯示 ~/.bashrc 的第 11 到第 20 行 *)
[root @test /root ]# nl [檔名]
參數說明:
#範例:
[root @test /root]# nl ~/.bashrc %*<==同 cat -n ~/.bachrc*)
[root@dywHome2 test]# od NAME
#範例:
[root@dywHome2 test]# od foo
0000000 064124 071551 064440 020163 020141 062564 072163 063040
0000020 066151 020145 067546 020162 060543 027164 047412 020513
0000040 062411 062566 074562 064164 067151 020147 071551 047440
0000060 027113 000012
0000063
練習題
<tab>
按鍵也以特殊符號顯示,應該如何下達指令?