Linux 命令(文件和目录管理 - more/less)
来源:互联网 发布:java架构师工作 编辑:程序博客网 时间:2024/06/05 11:49
简述
使用 cat 命令查看文件时,如果文件有很多内容,会出现滚屏现象,这时可以使用 more 或者 less 命令来查看,more 和 less 可以单独使用,也可以和其他命令组合使用。
- 简述
- 命令介绍
- 命令选项
- 交互式命令
- 使用范例
命令介绍
命令名称
more基本语法
more [选项] 文件…功能描述
more 是 一个过滤器,用于分页显示(一次一屏)文本。
命令选项
-d
显示帮助,而不是响铃 -f
统计逻辑行数而不是屏幕行数 -l
抑制换页(form feed)后的暂停 -p
不滚屏,清屏并显示文本 -c
不滚屏,显示文本并清理行尾 -u
抑制下划线 -s
将多个空行压缩为一行 -NUM
指定每屏显示的行数为 NUM +NUM
从文件第 NUM 行开始显示 +/STRING
从匹配搜索字符串 STRING 的文件位置开始显示 -V
显示版本信息并退出交互式命令
more 的交互命令基于 vi
,有些命令以一个十进制数字开始,在下面的描述里称之为 k
。后面的描述中,^X
指 control-X
。
h 或 ?
:帮助,显示这些命令的摘要,如果忘掉所有其他的命令, 请记住这个。SPACE
:显示接下来的 k 行文本,缺省值是当前的屏幕大小。z
:显示接下来的 k 行文本,缺省值是当前的屏幕大小,参数成为新的缺省值。RETURN
:显示接下来的 k 行文本,缺省值是 1,参数成为新的缺省值。d 或 ^D
:卷屏 k 行,缺省值是当前的卷屏大小,初始化为 11,参数成为新的缺省值。q 或 Q 或 INTERRUPT
:退出 more 命令s
:向前跳过 k 行文本,缺省值是 1。f
:向前跳过 k 屏文本,缺省值是 1。b 或 ^B
:向后跳回 k 屏文本,缺省值是 1。'
:跳到上一次搜索开始的地方。=
:显示当前行号/pattern
:搜索第 k 个 符合正则表达式的文本串,缺省值是 1。n
:搜索最后第 k 个符合正则表达式的文本串,缺省值是 1。!<cmd>
或:!<cmd>
:在子 shell 中执行<cmd>
。v
:启动/usr/bin/vi
,指向当前行。^L
:刷新屏幕。:n
:跳到后面第 k 个文件,缺省值是 1。:p
:跳到前面第 k 个文件,缺省值是 1。:f
:显示当前文件名和行号。.
:重复上次命令。
more 命令一次显示一屏文本,满屏后停下来,并且在屏幕的底部出现一个提示信息,给出至今己显示的该文件的百分比:--More--(XX%)
,可以用上述命令进行交互。
使用范例
1.查看文件内容
查看一个关于 Python 安装包中的 README 文件,由于文件内容过多,使用 more README
来分页显示。
[root@localhost Python-3.5.2]# more README This is Python version 3.5.2============================Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,2012, 2013, 2014, 2015, 2016 Python Software Foundation. All rights reserved.Python 3.x is a new version of the language, which is incompatible with the2.x line of releases. The language is mostly the same, but many details,especially how built-in objects like dictionaries and strings work,have changed considerably, and a lot of deprecated features have finallybeen removed.Build Instructions------------------On Unix, Linux, BSD, OSX, and Cygwin: ./configure make make test sudo make installThis will install Python as python3.You can pass many options to the configure script; run "./configure --help" tofind out more. On OSX and Cygwin, the executable is called python.exe;elsewhere it's just python.On Mac OS X, if you have configured Python with --enable-framework, you shoulduse "make frameworkinstall" to do the installation. Note that this installsthe Python executable in a place that is not normally on your PATH, you maywant to set up a symlink in /usr/local/bin.On Windows, see PCbuild/readme.txt.If you wish, you can create a subdirectory and invoke configure from there.For example:--More--(15%)
可以看到,屏幕的底部出现一个提示信息,给出至今己显示的该文件的百分比(15%)。
2.设定每屏显示行数
使用选项 -NUM
,指定每屏显示的行数为,这里指定显示 5 行。
[root@localhost Python-3.5.2]# more -5 README This is Python version 3.5.2============================Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,2012, 2013, 2014, 2015, 2016 Python Software Foundation. All rights reserved.--More--(2%)
3.从文件第 NUM 行开始显示
使用选项 +NUM
,从文件第 NUM 行开始显示,这里从第 10 行开始显示。
[root@localhost Python-3.5.2]# more +10 README have changed considerably, and a lot of deprecated features have finallybeen removed.Build Instructions------------------On Unix, Linux, BSD, OSX, and Cygwin: ./configure make make test sudo make installThis will install Python as python3.You can pass many options to the configure script; run "./configure --help" tofind out more. On OSX and Cygwin, the executable is called python.exe;elsewhere it's just python.On Mac OS X, if you have configured Python with --enable-framework, you shoulduse "make frameworkinstall" to do the installation. Note that this installsthe Python executable in a place that is not normally on your PATH, you maywant to set up a symlink in /usr/local/bin.On Windows, see PCbuild/readme.txt.If you wish, you can create a subdirectory and invoke configure from there.For example: mkdir debug cd debug ../configure --with-pydebug make make test(This will fail if you *also* built at the top-level directory.You should do a "make clean" at the toplevel first.)--More--(18%)
4.从匹配搜索字符串 STRING 的文件位置开始显示
使用选项 +/STRING
,从文件中查找第一个出现“Unix”字符串的行,并从该处前两行开始显示输出。
[root@localhost Python-3.5.2]# more +/Unix README ...跳过------------------On Unix, Linux, BSD, OSX, and Cygwin: ./configure make make test sudo make installThis will install Python as python3.You can pass many options to the configure script; run "./configure --help" tofind out more. On OSX and Cygwin, the executable is called python.exe;elsewhere it's just python.On Mac OS X, if you have configured Python with --enable-framework, you shoulduse "make frameworkinstall" to do the installation. Note that this installsthe Python executable in a place that is not normally on your PATH, you maywant to set up a symlink in /usr/local/bin.On Windows, see PCbuild/readme.txt.If you wish, you can create a subdirectory and invoke configure from there.For example: mkdir debug cd debug ../configure --with-pydebug make make test(This will fail if you *also* built at the top-level directory.You should do a "make clean" at the toplevel first.)If you need an optimized version of Python, you type "make profile-opt" in thetop level directory. This will rebuild the interpreter executable using ProfileGuided Optimization (PGO). For more details, see the section bellow.--More--(21%)
5.和其他命令组合使用
列出一个目录下的文件,如果内容过多,可以用 more 来分页显示,需要和管道 |
结合起来。
[root@localhost Python-3.5.2]# ls -l总用量 34676-rw-r--r--. 1 wang wang 8464 6月 26 05:38 aclocal.m4drwxr-xr-x. 5 root root 79 9月 7 20:30 build-rwxr-xr-x. 1 wang wang 42856 6月 26 05:38 config.guess-rw-r--r--. 1 root root 835023 9月 7 15:06 config.log-rwxr-xr-x. 1 root root 40031 9月 7 15:06 config.status-rwxr-xr-x. 1 wang wang 35740 6月 26 05:38 config.sub-rwxr-xr-x. 1 wang wang 474932 6月 26 05:38 configure-rw-r--r--. 1 wang wang 155069 6月 26 05:38 configure.acdrwxrwxr-x. 18 wang wang 4096 6月 26 05:47 Docdrwxrwxr-x. 2 wang wang 20 6月 26 05:38 Grammardrwxrwxr-x. 2 wang wang 4096 6月 26 05:38 Include-rwxr-xr-x. 1 wang wang 7122 6月 26 05:38 install-shdrwxrwxr-x. 47 wang wang 8192 9月 7 20:29 Lib-rw-r--r--. 1 root root 21053416 9月 7 20:29 libpython3.5m.a-rw-r--r--. 1 wang wang 12767 6月 26 05:38 LICENSEdrwxrwxr-x. 8 wang wang 4096 6月 26 05:38 Mac-rw-r--r--. 1 root root 66393 9月 7 15:06 Makefile-rw-r--r--. 1 root root 58147 9月 7 15:06 Makefile.pre-rw-r--r--. 1 wang wang 58449 6月 26 05:38 Makefile.pre.indrwxrwxr-x. 2 wang wang 4096 9月 7 15:06 Miscdrwxrwxr-x. 11 wang wang 8192 9月 7 20:29 Modulesdrwxrwxr-x. 4 wang wang 4096 9月 7 20:28 Objectsdrwxrwxr-x. 2 wang wang 4096 9月 7 20:28 Parserdrwxrwxr-x. 4 wang wang 4096 6月 26 05:38 PCdrwxrwxr-x. 2 wang wang 4096 6月 26 05:38 PCbuilddrwxrwxr-x. 2 wang wang 4096 9月 7 20:30 Programs-rw-r--r--. 1 root root 26 9月 7 20:29 pybuilddir.txt-rw-r--r--. 1 root root 43899 9月 7 15:06 pyconfig.h-rw-r--r--. 1 wang wang 41897 6月 26 05:38 pyconfig.h.in-rwxr-xr-x. 1 root root 12284727 9月 7 20:29 pythondrwxrwxr-x. 3 wang wang 4096 9月 7 20:29 Python-rw-r--r--. 1 root root 3080 9月 7 15:14 python-config-rw-r--r--. 1 root root 2042 9月 7 15:14 python-config.py-rw-r--r--. 1 root root 61170 9月 7 15:14 python-gdb.py-rw-r--r--. 1 wang wang 8060 6月 26 05:38 README-rw-r--r--. 1 wang wang 99778 6月 26 05:38 setup.pydrwxrwxr-x. 22 wang wang 4096 6月 26 05:38 Tools[root@localhost Python-3.5.2]# ls -l | more -5总用量 34676-rw-r--r--. 1 wang wang 8464 6月 26 05:38 aclocal.m4drwxr-xr-x. 5 root root 79 9月 7 20:30 build-rwxr-xr-x. 1 wang wang 42856 6月 26 05:38 config.guess-rw-r--r--. 1 root root 835023 9月 7 15:06 config.log--More--
less 命令的作用与 more 十分相似,都可以用来按页显示文件,不同之处在于 less 命令在显示文件时允许用户既可以向前又可以向后翻阅文件。而 more 命令只能向前浏览。用 less 命令显示文件时,用 PageUp 键向上翻页,用 PageDown 键向下翻页。若要在文件中往前移动,按 b 键;要移动到文件的百分比表示的某位置,则指定一个 0 ~ 100 之间的数,并按 p 键盘即可。less 命令使用与 more 类似,在此就不再赘述了,如有不清楚的地方查看联机帮助。
- Linux 命令(文件和目录管理 - more/less)
- linux命令--查看文件文件命令(more、cat、less)
- linux:less、more命令
- linux命令--less|more
- Linux的more和less命令
- Linux中more和less命令用法
- Linux中more和less命令用法
- Linux中more和less命令用法
- Linux中more和less命令用法
- Linux中more和less命令用法
- Linux中more和less命令用法
- Linux翻页命令more和less
- 【Linux文件目录命令】less命令
- linux文件目录操作命令 less
- linux之less/more命令
- Linux常见命令(more,less)
- 初学linux命令-more、less
- linux文件与目录的基本操作、linux命令(cp、tar、归档、ls、cd、tr、su、more、less、vi、cat等)
- android 基础 res文件 drawable
- POJ 2288 Islands and Bridges
- JS实现密码加密
- HTTP协议详解
- Android TextView实现跑马灯效果
- Linux 命令(文件和目录管理 - more/less)
- 开发笔记——检测键盘的弹出与消失
- 谷歌电子市场第4天总结
- [Android Studio 插件] AndroidPixelDimenGenerator 自动生成多种分辨率dimen文件
- 虚拟机和主机之间ping不通/开发板和虚拟机之间ping不通
- You need to run build with JDK or have tools.jar on the classpath.
- 2016/10/19
- HBase JAVA API 开发
- yii xss简单攻击