Created
October 18, 2023 08:03
-
-
Save Niall47/cd334771f25f14a39a917dc364309b42 to your computer and use it in GitHub Desktop.
Find binary script. Runs -v on each instance it finds.
This file contains 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 | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 <executable_name>" | |
exit 1 | |
fi | |
executable="$1" | |
IFS=':' read -ra path_dirs <<< "$PATH" | |
found=false | |
for dir in "${path_dirs[@]}"; do | |
if [ -x "$dir/$executable" ]; then | |
echo "Found: $dir/$executable" | |
found=true | |
"$dir/$executable" -v | |
fi | |
done | |
if [ "$found" = false ]; then | |
echo "Executable $executable not found in PATH." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment