Skip to content

Instantly share code, notes, and snippets.

@offlinemark
Last active August 29, 2015 13:59
Show Gist options
  • Save offlinemark/10519907 to your computer and use it in GitHub Desktop.
Save offlinemark/10519907 to your computer and use it in GitHub Desktop.
bash one-liner that enumerates your $PATH and finds any executables that match a certain substring (the string before the last semicolon). Useful for when you're pretty sure you have a certain command on your system but you're not exaclty sure what it's called and "man -k" or "apropos" are too verbose
for path in `echo $PATH | sed "s/:/ /g"`; do printf "\n$path\n-----\n\n" ; ls $path | grep hex; done
@offlinemark
Copy link
Author

example output:

$ for path in `echo $PATH | sed "s/:/ /g"`; do printf "\n$path\n-----\n\n" ; ls $path | grep cat; done

/usr/local/bin
-----

lzcat
ncat
netcat
xzcat

/usr/local/sbin
-----


/usr/bin
-----

bzcat
codesign_allocate
gencat
gzcat
locate
xmlcatalog
ypcat
zcat

/bin
-----

cat

/usr/sbin
-----

postcat
slapcat

/sbin
-----


/usr/local/bin
-----

lzcat
ncat
netcat
xzcat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment