使用特定的字符串在我的PATH中查找可执行文件 [英] find executables in my PATH with a particular string

查看:63
本文介绍了使用特定的字符串在我的PATH中查找可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以快速知道我的 $ PATH 中的可执行文件是否包含特定的字符串?例如,我要快速列出包含 SRA 的可执行文件.

Is there a way to quickly know whether an executable in my $PATH contains a particular string? For instance, I want to quickly list the executables that contain SRA.

我问的原因是我有几个脚本,其中包含字符 SRA .问题是我总是忘记文件的起始字符(如果我还记得的话,我会使用制表符补全来找到它).

The reason I'm asking is that I have several scripts with the characters SRA in them. The problem is that I always forget the starting character of the file (if I do remember, I use tab completion to find it).

推荐答案

您可以将所有路径存储在数组中,然后使用 find 及其各种选项:

You can store all the paths in an array and then use find with its various options:

IFS=":" read -ra paths <<< "$PATH"
find "${paths[@]}" -type f -executable -name '*SRA*'

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆