linux - Less - 一次搜索多个文件

标签 linux unix logging less

您好,我想知道是否可以使用 less 一次搜索多个文件。我面临的问题是,我应该遍历多个日志(instance1.log、instance2.log、instance3.log ...)并搜索一些测试。现在,我可以使用 less instance?.log 在 less 中打开多个文件,但我需要手动搜索文件并单独搜索每个文件,但我想搜索所有文件他们立刻。有这样的选择吗?

最佳答案

来自 less 手册页中的 /pattern 命令:

          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:

...

          ^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  line
                 list.

例如,使用 less 打开多个文件:

less file1 file2

然后输入 /^E/*,然后输入您的搜索模式。使用 n 在模式匹配中向前导航,使用 shift+n 在模式匹配中向后导航(跨多个文件)。

关于linux - Less - 一次搜索多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70507214/

相关文章:

linux - 如何让bash for循环退出?

linux - Bash 脚本检查远程运行命令的权限

php - 使用 PHP 解析 "top"命令(Shell)的输出

linux - 按日期将 Linux 终端输出记录到文件?

java - 获取用于记录的类名

ios - 临时应用程序构建中的错误记录和检索?

linux - 树莓派 : make command not working with below makefile

linux - 未链接的文件和 posix_fadvise(POSIX_FADV_NOREUSE)

Ruby 系统调用获取有关命令失败的信息

c - 编译器如何以及为什么将 extern 函数替换为空函数?