1、cat
NAME
cat - concatenate files and print on the standard output
連接所有指定文件并將結果寫到標準輸出。【經常用來顯示文件的內容,類似DOS的TYPE 命令】
SYNOPSIS
cat [OPTION]... [FILE]...
cat [選項]... [文件]...
With no FILE, or when FILE is -, read standard input.
如果沒有指定文件,或者文件為"-",則從標準輸入讀取。
cat命令有兩項功能:
一是顯示文件的內容,以此讀取由參數file指明的文件,將他們的內容輸出到標準輸出上;
二是連接兩個或多個文件,如“cat f1 f2 > f3”將把文件f1和f2的內容合并起來,然后通過輸出重定向符“>”,將它們放入文件f3中。
示例
cat f - g ?先輸出f 的內容,然后輸出標準輸入的內容,最后輸出g 的內容。
cat ? ? ? ?將標準輸入的內容復制到標準輸出。
【設m1和m2時當前目錄下的兩個文件】
$ cat m1 (在屏幕上顯示文件m1的內容)
$ cat m1 m2 (同時顯示文件m1和m2的內容)
常用選項
? ? ? ?-A, --show-all
? ? ? ? ? ? ? equivalent to -vET
? ? ? 等價于 -vET
? ? ? ?-b, --number-nonblank
? ? ? ? ? ? ? number nonempty output lines, overrides -n
? ? ? 從1開始對所有非空輸出行編號,覆蓋 -n
? ? ? ?-e ? ? equivalent to -vE?等價于 -vE
? ? ? ?-E, --show-ends
? ? ? ? ? ? ? display $ at end of each line
? ? ? 在每行結束處顯示?$
? ? ? ?-n, --number
? ? ? ? ? ? ? number all output lines
? ? ??從1開始對所有輸出行編號
? ? ? ?-s, --squeeze-blank
? ? ? ? ? ? ? suppress repeated empty output lines
? ? ? 將多個相鄰的空行合并成一個空行
? ? ? ?-t ? ? equivalent to -vT?與-vT 等價
? ? ? ?-T, --show-tabs
? ? ? ? ? ? ? display TAB characters as ^I
? ? ??將Tab顯示為^I
? ? ? ?-u ? ? (ignored)?(被忽略)
? ? ? ?-v, --show-nonprinting
? ? ? ? ? ? ? use ^ and M- notation, except for LFD and TAB
? ? ? 除了LFD和 TAB 之外使用^ 和M- 引用
? ? ? ?--help display this help and exit 顯示此幫助信息并退出
? ? ? ?--version output version information and exit 顯示版本信息并退出
注意
當文件較大時,文本在屏幕上迅速閃過(滾屏),用戶往往看不清所顯示的內容,因此一般用more等命令分屏顯示。為了控制滾屏,課用Ctrl+S鍵,停止滾屏;Ctrl+Q鍵,回復滾屏;Ctrl+C鍵(中斷),可以終止命令的執行,并且返回shell提示符狀態。
tac 是將 cat 反寫過來,所以它的功能就跟 cat 相反,cat 是由第一行到最后一行連續顯示在屏幕上,而 tac 則是由最后一行到第一行反向在屏幕上顯示出來
2、more
NAME
more - file perusal filter for crt viewing?適合屏幕查看的文件閱讀輸出工具。
SYNOPSIS
more [options] file...??more [選項] <文件>...
常用選項
? ? ? -d ? ? Prompt with "[Press space to continue, 'q' to ?quit.]", ?and ?display ?"[Press ?'h' ?for
? ? ? ? ? ? ? instructions.]" instead of ringing the bell when an illegal key is pressed.
? ? ? 在每屏的底部顯示以下更友好的提示信息:
? ? ? --更多--(21%)[Press space to continue, 'q' to ?quit.]
? ?? 當用戶按鍵有錯誤時,則顯示[Press ?'h' ?for instructions.]信息,而不是簡單報警。
? ? ? ?-l ? ? Do not pause after any line containing a ^L (form feed). 屏蔽換頁 [^L] (form feed)后的暫停
? ? ? ?-f ? ? Count logical lines, rather than screen lines (i.e., long lines are not folded).
? ? ?? 計算邏輯行數,而不是屏幕行數(即,不折疊長行)。
? ? ? ?-p ? ? Do ?not scroll. ?Instead, clear the whole screen and then display the text. ?Notice that
? ? ? ? ? ? ? this option is switched on automatically if the executable is named page.
? ? ? ? ? ? ? 不滾動,顯示文本并清理行末。注意這個頁面上的選項是自動切換的。
? ? ? ?-c ? ? Do not scroll. ?Instead, paint each screen from the top, clearing the remainder of ?each
? ? ? ? ? ? ? line as it is displayed.
? ? ??不滾動,清除屏幕并顯示文本,從頂部繪制每個屏幕,在顯示時清除每行的剩余部分。
? ? ? ?-s ? ? Squeeze multiple blank lines into one. 將文件中連續的空白行壓縮成一個空白行顯示
? ? ? ?-u ? ? Suppress underlining.?把文件內容中的下畫線去掉
? ? ?? -number
? ? ? ? ? ? ? The screen size to use, in number of lines.
? ? ? ? ? ? ? 指定一個整數num,表示一屏顯示多少行
? ? ? ?+number
? ? ? ? ? ? ? Start displaying each file at line number.
? ? ?? 從指定行開始顯示文件
? ? ? ?+/string
? ? ? ? ? ? ? The string to be searched in each file before starting to display it.?
? ? ? 從匹配搜索字符串的位置開始顯示文件
說明
more命令是一個基于vi編輯器的文本過濾器,以全屏幕形式顯示文件內容。
more命令一次顯示一瓶文本(file文件),滿屏后停下來,并且在屏幕底部出現一個提示信息,給出至今已顯示的該文件的百分比“--更多--(xx%)”。
可以用下列不同的方法對提示作出回答:
- 按Space鍵,顯示文本的下一屏內容。
- 按Enter鍵,只顯示文本的下一行內容。
- 按“/”鍵,接著輸入一個模式,可以在文本中尋找下一個相匹配的模式。
- 按h鍵或?鍵,顯示幫助屏,其中有相關的幫助信息。
- 按B鍵或^B,顯示上一屏內容。
- 按Q鍵,退出more命令。
示例
1、顯示文件mfile的內容,在顯示之前先清屏,并在屏幕下方顯示完整的百分比。
$ more -dc mfile
2、顯示文件mfile的內容,每10行顯示一次,而且在顯示之前先清屏。
$ more -c -10 mfile