admin管理员组

文章数量:1535516

Linux中more命令的功能

在Linux系统中,当我们需要在上面查看文件的时候,我们需要分页显示,这个时候就可以用到这个more命令。

more 命令类似 cat ,不过会以一页一页的形式显示,更方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会往回(back)一页显示。

more命令的基本入门

使用more命令,只需要在命令的后面跟上文件名称即可

more fileName

看下面这个实例

[root@xtgfgggff logs]# more catalina.2019-08-19.log

Aug 19, 2019 1:32:39 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 1:55:48 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 2:03:11 AM org.apache.catalina.core.StandardServer await

WARNING: StandardServer.await: Invalid command '' received

Aug 19, 2019 2:18:36 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 2:39:43 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 3:00:38 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 3:36:27 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 7:15:48 PM org.apache.catalina.core.StandardServer await

INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.

Aug 19, 2019 7:15:48 PM org.apache.coyote.AbstractProtocol pause

INFO: Pausing ProtocolHandler ["http-bio-80"]

Aug 19, 2019 7:15:48 PM org.apache.coyote.AbstractProtocol pause

INFO: Pausing ProtocolHandler ["ajp-bio-8009"]

Aug 19, 2019 7:15:48 PM org.apache.catalina.core.StandardService stopInternal

INFO: Stopping service Catalina

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a m

emory leak, the JDBC Driver has been forcibly unregistered.

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.

Aug 19, 2019 7:15:48 PM

--More--(6%)

查看下一行,请按回车键

查看下一屏,请按空格键

返回查看上一屏,请按b键

退出more命令,请按q键

more命令搜索字符串的功能

1.看如下命令:

more catalina.2019-08-19.log -20 +/2019

参数说明:

-num 一次显示的行数

+/pattern 在每个文档显示前搜寻该字串(pattern),然后从该字串之后开始显示

[root@xtgfgggff logs]# more catalina.2019-08-19.log -20 +/2019

::::::::::::::

catalina.2019-08-19.log

::::::::::::::

Aug 19, 2019 1:32:39 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 1:55:48 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 2:03:11 AM org.apache.catalina.core.StandardServer await

WARNING: StandardServer.await: Invalid command '' received

Aug 19, 2019 2:18:36 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 2:39:43 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 3:00:38 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 3:36:27 AM org.apache.coyote.http11.AbstractHttp11Processor process

INFO: Error parsing HTTP request header

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

Aug 19, 2019 7:15:48 PM org.apache.catalina.core.StandardServer await

INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.

Aug 19, 2019 7:15:48 PM org.apache.coyote.AbstractProtocol pause

INFO: Pausing ProtocolHandler ["http-bio-80"]

Aug 19, 2019 7:15:48 PM org.apache.coyote.AbstractProtocol pause

INFO: Pausing ProtocolHandler ["ajp-bio-8009"]

Aug 19, 2019 7:15:48 PM org.apache.catalina.core.StandardService stopInternal

INFO: Stopping service Catalina

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a m

emory leak, the JDBC Driver has been forcibly unregistered.

--More--(5%)

2.在已经显示的文件内容搜索匹配的字符串

2.1:使用more基本查看命令

more catalina.2019-08-19.log

2.2:按下V键,调用vi编辑器

结果:--More--(5%)看不见了,进入了vim模式

2.3:输入/,后面在跟你需要搜索的字符串。

/2019

2.4:然后按下回车,就搜到你要的字符串了,按n是匹配当前文本的下一个字符串

2.5:退出vim模式,按Esc键,输入:q 就可以退出vim,返回more命令格式

more命令从指定行开始显示

从第 20 行开始显示 catalina.2019-08-19.log之文档内容。

more +20 catalina.2019-08-19.log

+num 从第 num 行开始显示

more命令限制每页的行数

查看catalina.2019-08-19.log之文档内容,当前屏幕只显示20条

more -20 catalina.2019-08-19.log

-num 一次显示的行数

当我们按下空格键的时候,会显示下20行的内容,但是屏幕终端一共就显示了40行的内容,不利于查看,因为刚刚的20行内容我们已经看到过了。添加-c参数

more -20 -c catalina.2019-08-19.log

按下空格键,屏幕终端每次都只会显示20条。

Aug 19, 2019 7:15:48 PM org.apache.catalina.core.StandardServer await

INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.

Aug 19, 2019 7:15:48 PM org.apache.coyote.AbstractProtocol pause

INFO: Pausing ProtocolHandler ["http-bio-80"]

Aug 19, 2019 7:15:48 PM org.apache.coyote.AbstractProtocol pause

INFO: Pausing ProtocolHandler ["ajp-bio-8009"]

Aug 19, 2019 7:15:48 PM org.apache.catalina.core.StandardService stopInternal

INFO: Stopping service Catalina

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a m

emory leak, the JDBC Driver has been forcibly unregistered.

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it.

This is very likely to create a memory leak.

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it.

This is very likely to create a memory leak.

Aug 19, 2019 7:15:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

--More--(7%)

-c 显示内容再清除其他旧资料

微信公众号:51码农网

本文标签: 下一页命令Linux