【Linux常用命令】之more命令

Linux常用命令之more命令

作者简介

听雨:一名在一线从事多年研发的程序员,从事网站后台开发,熟悉java技术栈,对前端技术也有研究,同时也是一名骑行爱好者。
Darren:一个工作经验用了N年的,资深划水人士,除了工作无其他爱好

口号:记录在开发中遇到日常问题、棘手问题的解法和思路

常用命令之more

背景介绍

more 是分页显示文本文件内容,如果文本文件内容过多较长,使用cat则会读取后很难看清,这时如果有个可以分页的命令就更合适了。只要有需求就有人去实现,这不来了个more命令

常用参数

参数解释
-c不滚屏,先显示内容再清除旧内容
-s多个空行压缩成一行显示
-数字设置每屏显示的最大行数
+数字设置从指定的行开始显示内容
+/关键字从指定的行开始显示内容

例如

root@master:~/temp/more# more moretest.txt 
And as I gave it to him my heart was torn. 当我递给他时,我的心里千愁万绪。








“You have plans that I do not know about,” I said. “你有一些我不知道的计划,”我说。

But he did not answer me. 但他没回答。

He said to me, instead: “You know, my descent to the earth... 他对我说,“你知道,从我落到地球上······

Tomorrow will be its anniversary.” Then, after a silence, he went on: “I came down very near here.” And he flushed. 到明天就满一年了。”他沉默了一阵,又接着说:“我就落在这儿附近。
”说着他脸红了。

And once again, without understanding why, I had a queer sense of sorrow. 我再一次意识到,我为什么感受到一种莫名的愁绪。
…………

先进行清屏操作,随后每次10行显示

root@master:~/temp/more# more -c -10 moretest.txt
And as I gave it to him my heart was torn. 当我递给他时,我的心里千愁万绪。








“You have plans that I do not know about,” I said. “你有一些我不知道的计划,”我说。

遇到多空行时显示一行空行

root@master:~/temp/more# more -s moretest.txt 
And as I gave it to him my heart was torn. 当我递给他时,我的心里千愁万绪。

“You have plans that I do not know about,” I said. “你有一些我不知道的计划,”我说。

But he did not answer me. 但他没回答。

He said to me, instead: “You know, my descent to the earth... 他对我说,“你知道,从我落到地球上······

Tomorrow will be its anniversary.” Then, after a silence, he went on: “I came down very near here.” And he flushed. 到明天就满一年了。”他沉默了一阵,又接着说:“我就落在这儿附近。
”说着他脸红了。

从第10行显示

root@master:~/temp/more# more +10 moretest.txt 
“You have plans that I do not know about,” I said. “你有一些我不知道的计划,”我说。

But he did not answer me. 但他没回答。

He said to me, instead: “You know, my descent to the earth... 他对我说,“你知道,从我落到地球上······

Tomorrow will be its anniversary.” Then, after a silence, he went on: “I came down very near here.” And he flushed. 到明天就满一年了。”他沉默了一阵,又接着说:“我就落在这儿附近。
”说着他脸红了。

And once again, without understanding why, I had a queer sense of sorrow. 我再一次意识到,我为什么感受到一种莫名的愁绪。

找到关键字时显示

root@master:~/temp/more# more +/remember  moretest.txt 

...skipping
But I was not reassured. 但我放心不下。

I remembered the fox. 我想起了狐狸。

One runs the risk of weeping a little, if one lets himself be tamed... 如果一个人被驯服,就难免会流泪······

有时候会和gerp 组合使用,比如查找某个内容后,显示太多那就和more配合着使用,可以分页使用

root@master:~/temp/more# grep 'i' moretest.txt |more
And as I gave it to him my heart was torn. 当我递给他时,我的心里千愁万绪。
“You have plans that I do not know about,” I said. “你有一些我不知道的计

总结

more虽然是查看文件命令,主要是分页使用,根据场景区分不同的使用方法。

参考:《Linux常用命令自学手册》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值