我正在尝试less在 Linux 中运行,我希望它在启动后立即搜索某些内容。
基本上就像这样做:
$ less
Run Code Online (Sandbox Code Playgroud)
然后按'/',输入类似 的搜索模式"^commit \w+$",然后按 Enter,然后按'n'查找每个后续结果。
我希望少推出,然后搜索模式。手册页中似乎没有任何关于从模式开始的内容,但也许您可以像 Vim 一样向它发送命令。
Mat*_*hen 16
您可以使用 + 发送任意命令。例如:
less +/pattern
Run Code Online (Sandbox Code Playgroud)
-p PATTERN(由 nik 发布)相当于+/PATTERN.
gol*_*udo 10
从man页面:
-ppattern or --pattern=pattern
The -p option on the command line is equivalent to specifying
+/pattern; that is, it tells less to start at the first occur-
rence of pattern in the file.
Run Code Online (Sandbox Code Playgroud)
使用最新版本的less( 436 )可以按预期工作。