29 lines
591 B
Bash
Executable file
29 lines
591 B
Bash
Executable file
#!/bin/sh
|
|
# Where is the binary?
|
|
# Usage: what [<keyword>]
|
|
# Returns:
|
|
# With no parameters, all visible binaries in PATH.
|
|
# With parameter, all binaries that match the pattern
|
|
# given. Accepts default grep patterns, case insensitive
|
|
#
|
|
# Examples:
|
|
# $ what zs.*
|
|
# pzstd
|
|
# zsh
|
|
# zstd
|
|
#
|
|
# $ what ftp
|
|
# ftppass
|
|
# sftp
|
|
# vsftpd
|
|
#
|
|
# $ what ftp | xargs which
|
|
# /usr/bin/ftppass
|
|
# /usr/bin/sftp
|
|
# /usr/sbin/vsftpd
|
|
#
|
|
|
|
PWD=/
|
|
ALL_BINS=$(cd / && echo $PATH | sed 's/[:]/ /g' | xargs ls -A | grep -v ":" | sort | uniq)
|
|
OUTPUT=$(printf '%s\n' "-n" $ALL_BINS | grep -i "$1")
|
|
echo "$OUTPUT"
|