Skip to content

Instantly share code, notes, and snippets.

@forestbaker
Last active September 29, 2015 17:22
Show Gist options
  • Save forestbaker/40478345e95a85dbfbff to your computer and use it in GitHub Desktop.
Save forestbaker/40478345e95a85dbfbff to your computer and use it in GitHub Desktop.
preload executable binaries into array by looping through directories in $PATH
# for loop on directories in PATH
for foo in ${PATH//:/ }; do
done
# use mapfile to load binaries
# just loads up element 0
mapfile _binary <${PATH//:/\/\* }
readarray = mapfile != hash
for foo in * ; do
test -f “$x” || continue
COMMAND “$x”
done
while IFS=: read -r $PATH;
do
#do something with "$f"
rm -f "$f"
done
# source: https://gist.github.com/forquare/4637753f3c3c742aab63#file-whenceman-command
# whenceman to find man pages
function whenceman {
for i in "$(echo $MANPATH)" | sed "s/:/ /g"`; do
"$(find $i 2>/dev/null | grep -i $@)"
done
}
# whence
# pass binary names as parameters
whence() {
for i in "$(echo $PATH | sed "s/:/ /g")"; do
"$(ls $i/$@ 2>/dev/null)"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment