Created
July 20, 2015 18:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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