美文网首页
[Linux Tips] 如何搜索命令

[Linux Tips] 如何搜索命令

作者: BeeBee生信 | 来源:发表于2021-07-26 10:49 被阅读0次

虽然 Linux 的自动补齐超级好用,但难免偶尔不记得命令开头,却记得命令包含一些字母,此时非常希望能像 R 语言那样模糊搜索可能的命令(函数)。

??test
Vignettes with name or keyword or title matching ‘test’ using regular
expression matching:


checkmate::tinytest     Setup tinytest
coin::Implementation    Implementing a Class of Permutation Tests: The
                        coin Package
coin::MAXtest           Order-restricted Scores Test
  Concepts: robust trend test, maximum test
... # 省略剩余结果    

在 Linux 结合使用 compgen 和 grep 命令实现类似功能。compgen 命令能够输出系统所有可用的命令、内置函数、别名等等。用 -c 参数显示所有命令,再用 grep 筛选结果。

$ compgen -c | grep "top" | head -n 5
getopts
start-stop-daemon
xpmtoppm
imgtoppm
spctoppm

显示所有别名用 -a 参数。

$ compgen -a | head -n 5
alert
egrep
fgrep
grep
ll

显示内置函数用 -b 参数。


$ compgen -b | head -n 5
.
:
[
alias
bg

-k 参数显示 bash 关键字。

$ compgen -k | head -n 5
if
then
else
elif
fi

相关文章

  • [Linux Tips] 如何搜索命令

    虽然 Linux 的自动补齐超级好用,但难免偶尔不记得命令开头,却记得命令包含一些字母,此时非常希望能像 R 语言...

  • 碎碎念 b

    Linux中的搜索命令 文件搜索命令locate 命令搜索命令 忘记是啥了 find命令,其中find命令有好多后...

  • Linux达人养成计划 I--学习笔记

    本篇涉及的知识点 Linux简介Linux安装Linux命令基本格式及文件处理命令Linux 文件搜索命令Linx...

  • Linux笔记

    1. linux基本命令 搜索 搜索java命令的路径 which -a java 比find快的locate搜索...

  • hadoop学习2

    Linux 的搜索命令 命令:find 任何搜索搜索范围越大占用的资源越多 所以在搜索的时候尽量缩小搜索的范围 语...

  • php的学习路程

    一.Linux方面 Linux常用命令 1. 文件处理命令 2. 权限管理命令 3. 帮助命令 4. 文件搜索命令...

  • grep命令 你可以理解为过滤

    [linux grep命令]1.作用Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文...

  • linux grep命令

    linux grep命令 1.作用 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文...

  • linux安装gitlab

    注意:linux命令1、全局搜索文件find / -name (文件名)2、显示输入过的命令history3、搜索...

  • 我常用的Linux系统的快捷方式

    标签: Linux Tips Newbie Bash的快捷键 命令行是Linux之所以强大的重要原因之一。当初最早...

网友评论

      本文标题:[Linux Tips] 如何搜索命令

      本文链接:https://www.haomeiwen.com/subject/zwwwmltx.html