1、命令概述
more命令用於將內容較長的文本文件內容(不能在一屏顯示完)進行分屏顯示,並且支持在顯示時定位關鍵字。而對於內容較少的文本文件內容則推薦使用cat命令查看。
2、命令語法
more 【選項】 【文件】
3、命令選項
-num 指定每屏顯示num行
+num 從第 num 行開始顯示
+/pattern 在每個文檔顯示前搜尋該字(pattern),然后從該字串前兩行之后開始顯示
-l 取消遇見特殊字元 ^L(送紙字元)時會暫停的功能
-f 計算實際的行數,而非自動換行的行數(有些單行字數太長的會被擴展為兩行或兩行以上)
-p 先清除屏幕再顯示文本文件的剩余內容
-c 與-p相似,不滾屏,先顯示內容再清除舊內容
-s 多個空行壓縮成一行顯示
-u 不顯示下划線
-d 提示“Press space to continue,’q’ to quit(按空格鍵繼續,按q鍵退出)”,禁用響鈴功能
命令內部操作:
Space鍵:顯示文本的下一屏內容
Enter鍵:向下n行,需要定義,默認為1行
q鍵:退出more命令
Ctrl+f:向下滾動一屏
Ctrl+b:返回上一屏
=: 輸出當前的行號
:f:輸出文件名和當前的行號
v:調用vi編輯器
!:調用Shell,並執行命令
h:顯示幫助屏
4、命令示例
4.1 -num 指定每屏顯示num行,more -10 /etc/ssh/sshd_config 每屏顯示10行
1 [root@localhost ~]# more -10 /etc/ssh/sshd_config 2 # $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $ 3 4 # This is the sshd server system-wide configuration file. See 5 # sshd_config(5) for more information. 6 7 # This sshd was compiled with PATH=/usr/local/bin:/usr/bin 8 9 # The strategy used for options in the default sshd_config shipped with 10 # OpenSSH is to specify options with their default value where 11 # possible, but leave them commented. Uncommented options override the 12 --More--(11%)
4.2 +num 從第 num 行開始顯示,more + 10 /etc/ssh/sshd_config 從第10行開始顯示
4.3 +/pattern 在每個文檔顯示前搜尋該字(pattern),然后從該字串之后開始顯示;more +/Port /etc/ssh/sshd_config 從包含Port字符的前兩行開始顯示
1 [root@localhost ~]# more +/Port /etc/ssh/sshd_config 2 3 ...跳過 4 # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER 5 # 6 Port 28256 7 #AddressFamily any 8 #ListenAddress 0.0.0.0 9 #ListenAddress :: 10 11 HostKey /etc/ssh/ssh_host_rsa_key 12 #HostKey /etc/ssh/ssh_host_dsa_key 13 HostKey /etc/ssh/ssh_host_ecdsa_key 14 HostKey /etc/ssh/ssh_host_ed25519_key 15 16 # Ciphers and keying 17 #RekeyLimit default none
4.4 從文件中查找第一個出現"abc"字符串的行,並從該行前兩行開始到最后一行輸出為新文件
1 [root@localhost ~]# more +/abc work.txt > work1.txt