Created
August 7, 2018 10:29
-
-
Save StefanoBelli/ead2177a1a367ae22fcf798be17ca3a1 to your computer and use it in GitHub Desktop.
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 | |
| # guess prefix based on an installed program | |
| # | |
| # give a program on your own | |
| # ./guess-prefix.sh gcc | |
| # | |
| # or let the program consider "make" | |
| # ./guess-prefix.sh | |
| # | |
| # STDOUT: /usr | |
| PROG="$1" | |
| if [ $# -lt 1 ]; then | |
| PROG="make" | |
| fi | |
| WHAT=$(which $PROG) | |
| ARR=(${WHAT//// }) | |
| FINAL_STR="" | |
| for p in ${ARR[@]}; do | |
| if [[ $p == "bin" ]]; then | |
| break | |
| fi | |
| FINAL_STR=$FINAL_STR"/"$p | |
| done | |
| echo $FINAL_STR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment