less查看文本

2024-08-24 13:58
文章标签 查看 文本 less

本文主要是介绍less查看文本,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

3.14 less文本查看

3.14.1 语法

less [参数] 文件名
less - opposite of more

3.14.2 常用参数
  • 基础操作
    【-b <缓冲区大小>】设置缓冲区的大小
    【-e】当文件显示结束后,自动离开
    【-f】强迫打开特殊文件,例如外围设备代号、目录和二进制文件
    【-g】只标识最后搜索的关键词
    【-i】忽略搜索时的大小写
    【-m】显示类似more命令的百分比
    【-N】显示每行的行号
    【-o <文件名>】将less输出的内容在指定文件中保存起来
    【-Q】不使用警告音
    【-s】显示连续空行为一行
    【-S】行过长时间将长处部分舍弃
    【-x <数字>】将“TAB”键显示为规定的数字空格(设置一个tab表示几个空格)

  • 阅读导航
    【/字符串】:向下搜索“字符串”
    【?字符串】:向上搜索“字符串”
    【n】重复前一个搜索(与/或?有关)
    【N】反向重复前一个搜索(与/或?有关)
    【b】向后翻一页
    【d】向后翻半页
    【h】显示帮助界面
    【Q】退出less命令
    【u】向前滚动半页
    【y】向前滚动一行
    【空格键】滚动一页
    【回车键】滚动一行
    【pagedown】向下翻一页
    【pageup】向上翻一页

  • 全屏导航
    【ctrl+F】向前滚动一屏
    【ctrl+B】向后滚动一屏
    【ctrl+D】向前滚动半屏
    【ctrl+U】向后滚动半屏

  • 单行导航
    【j】向前移动一行
    【k】向后移动一行

  • 标记导航
    【ma】使用a标记文本的当前位置
    【'a】当行标记a处

  • 其他
    【G】移动到最后一行
    【g】移动到第一行
    【q/ZZ】退出less命令
    【v】进入编辑模式,编辑当前文件
    【h】显示less的帮助文档
    【&pattern】仅显示匹配模式的行,而不是整个文件

3.14.3 附加(man less)
NAMEless - opposite of moreSYNOPSISless -?less --helpless -Vless --versionless [-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~][-b space] [-h lines] [-j line] [-k keyfile][-{oO} logfile] [-p pattern] [-P prompt] [-t tag][-T tagsfile] [-x tab,...] [-y lines] [-[z] lines][-# shift] [+[+]cmd] [--] [filename]...(See the OPTIONS section for alternate option syntax with long option names.)DESCRIPTIONLess  is  a  program  similar to more (1), but which allows backward movement in the file as well as forward movement.  Also, less does not have to read the entire input file beforestarting, so with large input files it starts up faster than text editors like vi (1).  Less uses termcap (or terminfo on some systems), so it can run on  a  variety  of  terminals.There is even limited support for hardcopy terminals.  (On a hardcopy terminal, lines which should be printed at the top of the screen are prefixed with a caret.)Commands are based on both more and vi.  Commands may be preceded by a decimal number, called N in the descriptions below.  The number is used by some commands, as indicated.COMMANDSIn the following descriptions, ^X means control-X.  ESC stands for the ESCAPE key; for example ESC-v means the two character sequence "ESCAPE", then "v".h or H Help: display a summary of these commands.  If you forget all the other commands, remember this one.SPACE or ^V or f or ^FScroll  forward N lines, default one window (see option -z below).  If N is more than the screen size, only the final screenful is displayed.  Warning: some systems use ^V asa special literalization character.z      Like SPACE, but if N is specified, it becomes the new window size.ESC-SPACELike SPACE, but scrolls a full screenful, even if it reaches end-of-file in the process.RETURN or ^N or e or ^E or j or ^JScroll forward N lines, default 1.  The entire N lines are displayed, even if N is more than the screen size.d or ^DScroll forward N lines, default one half of the screen size.  If N is specified, it becomes the new default for subsequent d and u commands.b or ^B or ESC-vScroll backward N lines, default one window (see option -z below).  If N is more than the screen size, only the final screenful is displayed.w      Like ESC-v, but if N is specified, it becomes the new window size.y or ^Y or ^P or k or ^KScroll backward N lines, default 1.  The entire N lines are displayed, even if N is more than the screen size.  Warning: some systems use ^Y as a special job control  charac-ter.u or ^UScroll backward N lines, default one half of the screen size.  If N is specified, it becomes the new default for subsequent d and u commands.ESC-) or RIGHTARROWScroll horizontally right N characters, default half the screen width (see the -# option).  If a number N is specified, it becomes the default for future RIGHTARROW and LEFT-ARROW commands.  While the text is scrolled, it acts as though the -S option (chop lines) were in effect.ESC-( or LEFTARROWScroll horizontally left N characters, default half the screen width (see the -# option).  If a number N is specified, it becomes the default for future RIGHTARROW and  LEFT-ARROW commands.r or ^R or ^LRepaint the screen.R      Repaint the screen, discarding any buffered input.  Useful if the file is changing while it is being viewed.F      Scroll forward, and keep trying to read when the end of file is reached.  Normally this command would be used when already at the end of the file.  It is a way to monitor thetail of a file which is growing while it is being viewed.  (The behavior is similar to the "tail -f" command.)g or < or ESC-<Go to line N in the file, default 1 (beginning of file).  (Warning: this may be slow if N is large.)G or > or ESC->Go to line N in the file, default the end of the file.  (Warning: this may be slow if N is large, or if N is not specified and standard input, rather than a  file,  is  beingread.)p or % Go to a position N percent into the file.  N should be between 0 and 100, and may contain a decimal point.P      Go to the line containing byte offset N in the file.{      If a left curly bracket appears in the top line displayed on the screen, the { command will go to the matching right curly bracket.  The matching right curly bracket is posi-tioned on the bottom line of the screen.  If there is more than one left curly bracket on the top line, a number N may be used to specify the N-th bracket on the line.}      If a right curly bracket appears in the bottom line displayed on the screen, the } command will go to the matching left curly bracket.  The matching  left  curly  bracket  ispositioned on the top line of the screen.  If there is more than one right curly bracket on the top line, a number N may be used to specify the N-th bracket on the line.(      Like {, but applies to parentheses rather than curly brackets.)      Like }, but applies to parentheses rather than curly brackets.[      Like {, but applies to square brackets rather than curly brackets.]      Like }, but applies to square brackets rather than curly brackets.ESC-^F Followed by two characters, acts like {, but uses the two characters as open and close brackets, respectively.  For example, "ESC ^F < >" could be used to go forward to the >which matches the < in the top displayed line.ESC-^B Followed by two characters, acts like }, but uses the two characters as open and close brackets, respectively.  For example, "ESC ^B < >" could be used to go backward to  the< which matches the > in the bottom displayed line.m      Followed by any lowercase letter, marks the current position with that letter.’      (Single  quote.)   Followed  by  any lowercase letter, returns to the position which was previously marked with that letter.  Followed by another single quote, returns to theposition at which the last "large" movement command was executed.  Followed by a ^ or $, jumps to the beginning or end of the file respectively.  Marks are preserved  when  anew file is examined, so the ’ command can be used to switch between input files.^X^X   Same as single quote./patternSearch  forward  in the file for the N-th line containing the pattern.  N defaults to 1.  The pattern is a regular expression, as recognized by the regular expression librarysupplied by your system.  The search starts at the second line displayed (but see the -a and -j options, which change this).Certain characters are special if entered at the beginning of the pattern; they modify the type of search rather than become part of the pattern:^N or !Search for lines which do NOT match the pattern.^E or *Search multiple files.  That is, if the search reaches the END of the current file without finding a match, the search continues in the next file in the  command  linelist.^F or @Begin  the search at the first line of the FIRST file in the command line list, regardless of what is currently displayed on the screen or the settings of the -a or -joptions.^K     Highlight any text which matches the pattern on the current screen, but don’t move to the first match (KEEP current position).^R     Don’t interpret regular expression metacharacters; that is, do a simple textual comparison.?patternSearch backward in the file for the N-th line containing the pattern.  The search starts at the line immediately before the top line displayed.Certain characters are special as in the / command:^N or !Search for lines which do NOT match the pattern.^E or *Search multiple files.  That is, if the search reaches the beginning of the current file without finding a match, the search continues in the previous file in the com-mand line list.^F or @Begin  the  search  at the last line of the 

这篇关于less查看文本的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1102677

相关文章

Mysql实现范围分区表(新增、删除、重组、查看)

《Mysql实现范围分区表(新增、删除、重组、查看)》MySQL分区表的四种类型(范围、哈希、列表、键值),主要介绍了范围分区的创建、查询、添加、删除及重组织操作,具有一定的参考价值,感兴趣的可以了解... 目录一、mysql分区表分类二、范围分区(Range Partitioning1、新建分区表:2、分

Python中图片与PDF识别文本(OCR)的全面指南

《Python中图片与PDF识别文本(OCR)的全面指南》在数据爆炸时代,80%的企业数据以非结构化形式存在,其中PDF和图像是最主要的载体,本文将深入探索Python中OCR技术如何将这些数字纸张转... 目录一、OCR技术核心原理二、python图像识别四大工具库1. Pytesseract - 经典O

苹果macOS 26 Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色

《苹果macOS26Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色》在整体系统设计方面,macOS26采用了全新的玻璃质感视觉风格,应用于Dock栏、应用图标以及桌面小部件等多个界面... 科技媒体 MACRumors 昨日(6 月 13 日)发布博文,报道称在 macOS 26 Tahoe 中

Python实现精准提取 PDF中的文本,表格与图片

《Python实现精准提取PDF中的文本,表格与图片》在实际的系统开发中,处理PDF文件不仅限于读取整页文本,还有提取文档中的表格数据,图片或特定区域的内容,下面我们来看看如何使用Python实... 目录安装 python 库提取 PDF 文本内容:获取整页文本与指定区域内容获取页面上的所有文本内容获取

Windows的CMD窗口如何查看并杀死nginx进程

《Windows的CMD窗口如何查看并杀死nginx进程》:本文主要介绍Windows的CMD窗口如何查看并杀死nginx进程问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录Windows的CMD窗口查看并杀死nginx进程开启nginx查看nginx进程停止nginx服务

详解如何使用Python从零开始构建文本统计模型

《详解如何使用Python从零开始构建文本统计模型》在自然语言处理领域,词汇表构建是文本预处理的关键环节,本文通过Python代码实践,演示如何从原始文本中提取多尺度特征,并通过动态调整机制构建更精确... 目录一、项目背景与核心思想二、核心代码解析1. 数据加载与预处理2. 多尺度字符统计3. 统计结果可

如何确定哪些软件是Mac系统自带的? Mac系统内置应用查看技巧

《如何确定哪些软件是Mac系统自带的?Mac系统内置应用查看技巧》如何确定哪些软件是Mac系统自带的?mac系统中有很多自带的应用,想要看看哪些是系统自带,该怎么查看呢?下面我们就来看看Mac系统内... 在MAC电脑上,可以使用以下方法来确定哪些软件是系统自带的:1.应用程序文件夹打开应用程序文件夹

Linux查看系统盘和SSD盘的容量、型号及挂载信息的方法

《Linux查看系统盘和SSD盘的容量、型号及挂载信息的方法》在Linux系统中,管理磁盘设备和分区是日常运维工作的重要部分,而lsblk命令是一个强大的工具,它用于列出系统中的块设备(blockde... 目录1. 查看所有磁盘的物理信息方法 1:使用 lsblk(推荐)方法 2:使用 fdisk -l(

Linux中的more 和 less区别对比分析

《Linux中的more和less区别对比分析》在Linux/Unix系统中,more和less都是用于分页查看文本文件的命令,但less是more的增强版,功能更强大,:本文主要介绍Linu... 目录1. 基础功能对比2. 常用操作对比less 的操作3. 实际使用示例4. 为什么推荐 less?5.

MySQL查看表的最后一个ID的常见方法

《MySQL查看表的最后一个ID的常见方法》在使用MySQL数据库时,我们经常会遇到需要查看表中最后一个id值的场景,无论是为了调试、数据分析还是其他用途,了解如何快速获取最后一个id都是非常实用的技... 目录背景介绍方法一:使用MAX()函数示例代码解释适用场景方法二:按id降序排序并取第一条示例代码解