4000-520-616
欢迎来到免疫在线!(蚂蚁淘生物旗下平台)  请登录 |  免费注册 |  询价篮
主营:原厂直采,平行进口,授权代理(蚂蚁淘为您服务)
咨询热线电话
4000-520-616
当前位置: 首页 > 新闻动态 >
新闻详情
cat命令的作用是什么 - CSDN
来自 : CSDN技术社区 发布时间:2021-03-24

请关注本头条号,每天坚持更新原创干货技术文章。

如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习

1. more命令简介

本文主要介绍more命令,其作用类似 cat 。cat命令是一次性显示一个文件的所有内容,对于内容较多的文件,显然cat并不合适。 而more会以逐页的方式显示文件内容,使用过程中可按空白键(space)翻往下一页显示,按 b 键翻往(back)前一页,而且还有搜寻字串的功能 。more命令在启动时就加载整个文件,这也是与less命令的区别之一。

\"7b2593ebad11c3d1b9e4b1b6dbe4e88e.png\"

2. more命令选项

+n 从笫n行开始显示

-n 定义屏幕大小为n行

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

-c 从顶部清屏,然后显示

-d 提示“Press space to continue,’q’ to quit(按空格键继续,按q键退出)”,禁用响铃功能

-l 忽略Ctrl+l(换页)字符

-p 通过清除窗口而不是滚屏来对文件进行换页,与-c选项相似

-s 把连续的多个空行显示为一行

-u 把文件内容中的下画线去掉

3. 常用快捷方式

Enter 向下n行,需要定义。默认为1行

Ctrl+F 向下滚动一屏

空格键 向下滚动一屏

Ctrl+B 返回上一屏

= 输出当前行的行号

:f 输出文件名和当前行的行号

V 调用vi编辑器

!命令 调用Shell,并执行命令

q 退出more

4. 常用使用方法

4.1 指定行开始显示

从第4行开始打印某文件的内容,

[root@zcwyou zcwyou]# more +4 /etc/ssh/sshd_config
sshd_config(5) for more information.This sshd was compiled with PATH=/usr/local/bin:/usr/binThe strategy used for options in the default sshd_config shipped withOpenSSH is to specify options with their default value wherepossible, but leave them commented. Uncommented options override thedefault value.\"6017c5bf1e42c0060b252267442a1602.png\"

linuxmore从指定行开始显示

4.2 从特定关键字开始打印

从文件中查找第一个出现\"authentication\"字符串的行,并从该处前两行开始显示输出

[root@zcwyou zcwyou]# more +/authentication /etc/ssh/sshd_config 
\"a6ba2e3c8a22afc8f19f188b0e9fa74c.png\"

linux more从特定关键字开始打印

跳过

GSSAPIEnablek5users noSet this to \'yes\' to enable PAM authentication, account processing,and session processing. If this is enabled, PAM authentication willbe allowed through the ChallengeResponseAuthentication andPasswordAuthentication. Depending on your PAM configuration,PAM authentication via ChallengeResponseAuthentication may bypassthe setting of \"PermitRootLogin without-password\".If you just want the PAM account and session checks to run without

4.3 设定每屏显示行数

查看more手册,并设定每次只显示5行。

[root@zcwyou zcwyou]# man more |more -5

Ctrl+F 向下滚动一屏

空格键 向下滚动一屏

Ctrl+B 返回上一屏

4.4 使用more优化打印输出

查看进程时结合more打印内容

[root@zcwyou zcwyou]# ps -ef |more

UID PID PPID C STIME TTY TIME CMD

root 1 0 0 11月27 ? 00:00:30 /usr/lib/systemd/systemd --switched-root --system --deserialize 22

root 2 0 0 11月27 ? 00:00:00 [kthreadd]

root 3 2 0 11月27 ? 00:00:00 [rcu_gp]

root 4 2 0 11月27 ? 00:00:00 [rcu_par_gp]

root 6 2 0 11月27 ? 00:00:00 [kworker/0:0H-kb]

root 8 2 0 11月27 ? 00:00:00 [mm_percpu_wq]

root 9 2 0 11月27 ? 00:00:01 [ksoftirqd/0]

root 10 2 0 11月27 ? 00:00:28 [rcu_sched]

root 11 2 0 11月27 ? 00:00:00 [rcu_bh]

root 12 2 0 11月27 ? 00:00:00 [migration/0]

root 13 2 0 11月27 ? 00:00:00 [watchdog/0]

root 14 2 0 11月27 ? 00:00:00 [cpuhp/0]

\"a24ace44053e844776dc65bafadf2d6d.png\"

Linux使用more优化打印输出

5. 总结

more命令可以结合其他工具优化信息或者日志的输出,方便运维人员阅读输出信息。

收起 \"\" 展开全文 \"\"

本文链接: http://hetcat.immuno-online.com/view-681472.html

发布于 : 2021-03-24 阅读(0)