linux - 无法将程序与按双 Tab 键时的 Bash 总数相匹配

标签 linux bash shell path

Bash 中,如果我按两次 Tab 键,则会看到:

Display all 1092 possibilities? (y or n)

片段:

!         diff              ifconfig      mount.fuse        rcsdiff       tiff2pdf
./        diff3             ifdown        mount.ntfs-3g     rcsmerge      tiff2ps
:         diffutils-cmp     ifenslave     mount.ntfs-fuse   rdisc         tiff2rgba
GET       diffutils-diff    iftop         mountpoint        rdjpgcom      tiffcmp
HEAD      diffutils-diff3   ifup          msgattrib         read          tiffcp
MAKEDEV   diffutils-sdiff   ifup-local    msgcat            readelf       tiffdiff
POST      dig               igawk         msgcmp            readlink      tiffdither
[         dir               igd-client    msgcomm           readonly      tiffdump
--More--

我认为,如果我搜索 $PATH 环境变量中目录中的所有可执行文件,那么将会生成一个与 more 数据匹配的单列列表> 显示。

这是我的第一次尝试:

echo $PATH | sed -e 's/:/ /g' -e "s/^/find / " | sh > commandlist.txt
wc -l commandlist.txt
1114 commandlist.txt

所以我添加了 -xtype f-perm/u=x 但仍然没有得到 1092:

echo $PATH | sed -e 's/:/ /g' -e "s/^/find / " -e "s/$/ -xtype f -perm \/u=x/" | sh | wc -l
1107

Bash 中的双 Tab 键按下如何生成其总“可能性”值?

最佳答案

这似乎有效:

compgen -cab | sort | uniq | wc -l

在我的机器上,它显示的数字与选项卡完整的数字相同。

关于linux - 无法将程序与按双 Tab 键时的 Bash 总数相匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9446648/

相关文章:

linux - Apache HTTP Server Config Variable is not defined 错误 ***如何解决?***

linux - 使用特殊光标时,在 Ubuntu 上重新启动 freeglut/OpenGL C 应用程序失败

linux - IP_TRANSPARENT 用法

linux - 根据条件将 bash 中的 CSV 文件拆分为多个文件

linux - 如何在 awk 中运行 grep?

linux - 如何在子文件夹中同步文件模式

Linux:将DD结果输出到文本文件

bash - Jenkins 更新语法错误 : end of file unexpected (expecting ")") Execute Shell

javascript - 如何使用Coffeescript和shellJS编写可执行的shell脚本?

Linux 安全和/etc/shadow