您好,我想知道是否可以使用 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/