Skip to content

Instantly share code, notes, and snippets.

@zkxs
Created July 20, 2015 18:47
Show Gist options
  • Select an option

  • Save zkxs/8a3e1eff9cf377445d27 to your computer and use it in GitHub Desktop.

Select an option

Save zkxs/8a3e1eff9cf377445d27 to your computer and use it in GitHub Desktop.
Search for $1 on the path, and print the filename if we find it
#!/bin/bash
#magically arrayify $PATH
IFS=':' read -a arr <<< "$PATH"
# iterate
for i in "${arr[@]}"; do
# grep for arg 1
ls -1 "$i" | fgrep "$1"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment