Hau*_*ing 49 less case-sensitivity
试图找出如何使用不区分大小写的搜索,less
我在 serverfault 上找到了这个。
这似乎完美地回答了我的问题。问题是:它在这里不起作用(OpenSUSE 13.1;少于 458)。
我有别名less
,less -WiNS
但我改变了。但即使称之为 ascommand less file
也不会改变任何东西。我已经检查过命令行中ps
不再有任何-i
选项。
正如答案所说,less
帮助(按h
)指出我也可以-i
在 内使用less
。如果我使用一次,然后less
告诉我它已更改为不区分大小写的搜索(这是正确的:没有任何变化)。如果我使用它两次,然后less
告诉我它已转向区分大小写的搜索。是的,那么它从一开始就可以正常工作。但是-i
,在命令行上提供两次不起作用。
这是怎么回事?
slm*_*slm 65
我不确定如何从命令行启用它,但是当你在里面时,less
你可以通过将-i
命令提供给less
.
切换 -i
寻找/blah
和/BLAH
寻找 /Blah
显然,您也可以通过在搜索后添加-i
.
less prompt> /search string/-i
Run Code Online (Sandbox Code Playgroud)
Omi*_*mid 10
手册(对于我的less
444 版)说:
Options are also taken from the environment variable "LESS". For exam?
ple, to avoid typing "less -options ..." each time less is invoked, you
might tell csh:
setenv LESS "-options"
or if you use sh:
LESS="-options"; export LESS
On MS-DOS, you don't need the quotes, but you should replace any per?
cent signs in the options string by double percent signs.
The environment variable is parsed before the command line, so command
line options override the LESS environment variable.
On MS-DOS, you don't need the quotes, but you should replace any per?
cent signs in the options string by double percent signs.
The environment variable is parsed before the command line, so command
line options override the LESS environment variable. If an option
appears in the LESS variable, it can be reset to its default value on
the command line by beginning the command line option with "-+".
Run Code Online (Sandbox Code Playgroud)
所以,我会检查环境变量LESS
是否可能设置在某个地方,也许在你的 shell“点文件”中。此外,less -+i
应该将 重置-i
为其默认值(区分大小写)。如果这为您带来了区分大小写的功能,那么您可以只使用alias less=less -+i
,也许与alias lessi=less -i
.
小智 5
您可以通过传递 -i 选项来减少大小写并忽略大小写。这将忽略大小写,除非搜索字符串具有大写字符。以下是来自Ubuntu 帮助页面的less 摘要:
Run Code Online (Sandbox Code Playgroud)-i or --ignore-case Causes searches to ignore case; that is, uppercase and lowercase are considered identical. This option is ignored if any uppercase letters appear in the search pattern; in other words, if a pattern contains uppercase letters, then that search does not ignore case. -I or --IGNORE-CASE Like -i, but searches ignore case even if the pattern contains uppercase letters.
其他版本的 less 对 -i 的解释可能有所不同。
2 步快速指南: 进行搜索:
:/put search lowercase word here after slash
Run Code Online (Sandbox Code Playgroud)
然后在突出显示所有区分大小写的匹配项之后:
:-i
Run Code Online (Sandbox Code Playgroud)
无论大小写,这都将突出显示所有匹配项。
小智 5
当您打开文件时,您可以将参数传递给 less 命令,并且所有搜索都将不区分大小写。
$ less -i <file_name>
Run Code Online (Sandbox Code Playgroud)
或者您可以修改您的.bashrc
文件,以便您的 less 始终不区分大小写
export LESS="-i"
Run Code Online (Sandbox Code Playgroud)