0020. shell命令--more

目录

20. shell命令--more

功能说明

语法格式

选项说明

实践操作

交互式子命令说明

注意事项


20. shell命令--more

功能说明

        more 是 Linux 中的一个常用的命令行工具,用于分页显示文件内容。当文件内容过大,无法一次性在终端屏幕上完全显示时,more 命令允许用户按页查看文件内容。more 命令类似 cat ,不过会以一页一页的形式显示,更方便使用者逐页阅读。而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会往回(back)一页显示。而且还有搜寻字串的功能(与 vi 相似),使用中的说明文件,请按 h 。

语法格式

more [选项] 文件名

SYNOPSIS
    more [options] file [...]
    more [-dlfpcsu] [-num] [+/pattern] [+linenum] [fileNames..]

选项说明

  • -c:跟 -p 相似,不同的是先显示内容再清除其他旧资料
  • -s:当遇到有连续两行以上的空白行,就代换为一行的空白行
  • -u:不显示下引号 (根据环境变数 TERM 指定的 terminal 而有所不同)
  • +/pattern:在每个文档显示前搜寻该字串(pattern),然后从该字串之后开始显示
  • -num:一次显示的行数,也就是定义屏幕显示的行数,默认为 11 行
  • -d:提示使用者,在画面下方显示 [Press space to continue, 'q' to quit.] ,如果使用者按错键,则会显示 [Press 'h' for instructions.] 而不是 '哔' 声,提示用户按空格键继续或按 q 键退出(Linux 系统默认)
  • -l:取消遇见特殊字元 ^L(送纸字元)时会暂停的功能
  • -f:计算行数时,以实际上的行数,而非自动换行过后的行数(有些单行字数太长的会被扩展为两行或两行以上)
  • -p:不以卷动的方式显示每一页,而是先清除萤幕后再显示内容
  • +num:从第 num 行开始显示
  • fileNames:欲显示内容的文档,可为复数个数

实践操作

1. 分页显示指定的文本文件内容,当内容过多时,按空格键查看下一页,按 q 键退出。
more /etc/profile

2. 先进行清屏操作,随后以每次5行内容的格式显示指定的文本文件内容
more -c -5 /etc/profile

3. 分页显示指定的文本文件内容,若遇到连续两行及以上空白行的情况,则以一行空白行显示
more /etc/yum.conf
more -s /etc/yum.conf

4. 从第10行开始,分页显示指定的文本文件内容
cat -n /etc/yum.conf    #看一下文件行号
more +10 /etc/yum.conf    #从第十行显示
more +13 /etc/yum.conf    #从第十三行显示

5. 与管道符 | 结合使用,以便从其他命令的输出中分页查看内容
ls -l /etc/ | more
grep "Started" /var/log/messages | more

命令示例:1. 分页显示指定的文本文件内容,当内容过多时,按空格键查看下一页,按 q 键退出。

more /etc/profile

输出结果:

[root@MineGi ~]# more /etc/profile
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
--More--(33%)
...

命令示例:2. 先进行清屏操作,随后以每次5行内容的格式显示指定的文本文件内容

more -c -5 /etc/profile

输出结果:

[root@MineGi ~]# 
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

--More--(6%)
......

命令示例:3. 分页显示指定的文本文件内容,若遇到连续两行及以上空白行的情况,则以一行空白行显示

more /etc/yum.conf
more -s /etc/yum.conf

输出结果:

[root@MineGi ~]# more /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_r
eport_page.php?category=yum
distroverpkg=centos-release


#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
--More--(74%)
.....

命令示例:4. 从第10行开始,分页显示指定的文本文件内容

cat -n /etc/yum.conf
more +10 /etc/yum.conf
more +13 /etc/yum.conf 

输出结果:

[root@MineGi ~]# cat -n /etc/yum.conf
     1    [main]
     2    cachedir=/var/cache/yum/$basearch/$releasever
     3    keepcache=0
     4    debuglevel=2
     5    logfile=/var/log/yum.log
     6    exactarch=1
     7    obsoletes=1
     8    gpgcheck=1
     9    plugins=1
    10    installonly_limit=5
    11    bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
    12    distroverpkg=centos-release
    13    
    14    
    15    #  This is the default, if you make this bigger yum won't see if the metadata
    16    # is newer on the remote and so you'll "gain" the bandwidth of not having to
    17    # download the new metadata and "pay" for it by yum not having correct
    18    # information.
    19    #  It is esp. important, to have correct metadata, for distributions like
    20    # Fedora which don't keep old packages around. If you don't like this checking
    21    # interupting your command line usage, it's much better to have something
    22    # manually check the metadata once an hour (yum-updatesd will do this).
    23    # metadata_expire=90m
    24    
    25    # PUT YOUR REPOS HERE OR IN separate files named file.repo
    26    # in /etc/yum.repos.d
[root@MineGi ~]#
[root@MineGi ~]# more +10 /etc/yum.conf
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_r
eport_page.php?category=yum
distroverpkg=centos-release


#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[root@MineGi ~]# more +13 /etc/yum.conf 


#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[root@MineGi ~]# 

命令示例:5. 与管道符 | 结合使用,以便从其他命令的输出中分页查看内容

ls -l /etc/ | more
grep "Started" /var/log/messages | more

输出结果:

[root@MineGi ~]# ls -l /etc/ | more
总用量 1060
-rw-r--r--.  1 root root       16 11月 22 09:57 adjtime
-rw-r--r--.  1 root root     1529 4月   1 2020 aliases
-rw-r--r--.  1 root root    12288 11月 22 09:58 aliases.db
drwxr-xr-x.  2 root root      261 11月 22 10:07 alternatives
-rw-------.  1 root root      541 8月   9 2019 anacrontab
-rw-r--r--.  1 root root       55 8月   8 2019 asound.conf
drwxr-x---.  3 root root       43 11月 22 09:54 audisp
drwxr-x---.  3 root root       83 11月 22 09:58 audit
drwxr-xr-x.  2 root root       46 11月 22 10:07 bash_completion.d
-rw-r--r--.  1 root root     2971 11月 22 10:09 bashrc
drwxr-xr-x.  2 root root        6 10月  2 2020 binfmt.d
-rw-r--r--.  1 root root       37 10月 23 2020 centos-release
-rw-r--r--.  1 root root       51 10月 23 2020 centos-release-upstream
drwxr-xr-x.  2 root root        6 10月 13 2020 chkconfig.d
-rw-r--r--.  1 root root     1108 8月   8 2019 chrony.conf
-rw-r-----.  1 root chrony    481 8月   8 2019 chrony.keys
drwxr-xr-x.  2 root root       36 11月 22 10:07 cron.d
drwxr-xr-x.  2 root root       57 11月 30 2024 cron.daily
-rw-------.  1 root root        0 8月   9 2019 cron.deny
drwxr-xr-x.  2 root root       22 6月  10 2014 cron.hourly
[root@MineGi ~]# grep "Started" /var/log/messages | more
Nov 22 09:58:47 CentOS7 systemd[1]: Started Create list of required static device nodes for the curr
ent kernel.
Nov 22 09:58:47 CentOS7 systemd[1]: Started Create Static Device Nodes in /dev.
Nov 22 09:58:47 CentOS7 systemd[1]: Started Load Kernel Modules.
Nov 22 09:58:47 CentOS7 systemd[1]: Started Apply Kernel Variables.
Nov 22 09:58:47 CentOS7 systemd[1]: Started Journal Service.
Nov 22 09:58:47 CentOS7 systemd: Started Setup Virtual Console.
Nov 22 09:58:47 CentOS7 systemd: Started dracut cmdline hook.
Nov 22 09:58:47 CentOS7 systemd: Started dracut pre-udev hook.
Nov 22 09:58:47 CentOS7 systemd: Started udev Kernel Device Manager.
Nov 22 09:58:47 CentOS7 systemd: Started udev Coldplug all Devices.
Nov 22 09:58:47 CentOS7 systemd: Started Show Plymouth Boot Screen.
Nov 22 09:58:47 CentOS7 systemd: Started Forward Password Requests to Plymouth Directory Watch.
Nov 22 09:58:49 CentOS7 systemd: Started dracut initqueue hook.
Nov 22 09:58:49 CentOS7 systemd: Started File System Check on /dev/mapper/centos-root.
Nov 22 09:58:49 CentOS7 systemd: Started Reload Configuration from the Real Root.
Nov 22 09:58:49 CentOS7 systemd: Started dracut pre-pivot and cleanup hook.
Nov 22 09:58:49 CentOS7 systemd: Started Cleaning Up and Shutting Down Daemons.
Nov 22 09:58:49 CentOS7 systemd: Started Cleanup udevd DB.
Nov 22 09:58:49 CentOS7 systemd: Started Plymouth switch root service.
Nov 22 09:58:49 CentOS7 systemd: Started Read and set NIS domainname from /etc/sysconfig/network.
[root@MineGi ~]# 

交互式子命令说明

  • Ctrl+B:返回上一屏
  • =:输出当前行的行号
  • :f:输出文件名和当前行的行号
  • Enter:向下 n 行,需要定义。默认为1行
  • Ctrl+F:向下滚动一屏
  • 空格键:向下滚动一屏
  • V:调用 vi 编辑器
  • !命令:调用 Shell,并执行命令,比如:ls -a /root/
  • q:退出 more

注意事项

  • more 命令在查看大文件时可能不如 less 命令灵活,因为 less 允许用户向前和向后滚动浏览文件内容。
  • 对于大多数用户来说,less 命令更为常用,因为它提供了更多的功能和选项。但是,more 命令在某些情况下(如简单的文件查看)仍然很有用。

        尽管 more 命令在某些方面可能不如 less 命令强大,但它仍然具有一些高级功能和应用场景,使得在某些情况下它仍然是一个有价值的工具。

1. Log操作 2 2. 基站侧查看小区状态 2 3. 基站侧查看传输类型 2 4. RNC侧查看传输类型 3 5. 基站侧查看传输误码(累积值) 4 6. 基站测试传输误码 4 7. RNC侧查看传输误码(累积值) 5 8. 基站侧查看基站当前告警 6 9. 基站侧查看基站历史告警 6 10. 基站侧查看基站硬件状态 7 11. 查看ipdatabase所在目录 7 12. 查看整个RNC的所有小区状态 8 13. 检查RBS的CE 8 14. 检查是否有LICENSE文件 8 15. 检查LICENSE信息 9 16. 检查FEATURE设置 9 17. 检查LICENSE设置 10 18. 11 19. 检查RBS的类型 11 20. 检查RBS的当前驻波比 11 21. 检查当前天线的监控门限 12 22. 修改天线的监控门限 13 23. 在RNC得出参数设置值 13 24. 在RBS得出参数设置值 13 25. 查看该基站每个小区用户数 13 26. 查看基站的资源使用情况 14 27. 查看小区的资源使用情况 14 28. 查看某小区的所有3G邻区 15 29. 打印小区归属RNC的3G邻区 15 30. 打印小区的所有GSM邻区 16 31. 整个RNC的外部GSM邻区 16 32. GSM小区的定义参数 17 33. 查看话务统计 17 34. 打印以前输入的指令 18 35. 打印以前的修改记录 19 36. 打印时间 19javascript:void(0); 37. UNIX基本命令 19 38. 查询参数解释 20 39. 检查网口的状态 20 40. 查看基站传输是否断的步骤 20 41. 检查板子的历史记录 20 42. 数据比较 21 43. 历史操作记录 21 44. 重新设置RBS的登录密码 21 45. 重启RRU 21 46. 检查IP是否通 22 47. MOBATCH的应用 25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MineGi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值