-
-
Save prcongithub/ebd57a320823e01f103cf5e81a135c46 to your computer and use it in GitHub Desktop.
Get version for any command without worrying about the parameter to pass
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 [ -z "$1" ] | |
then | |
echo "Comand Argument Is Missing! Try get_version java" | |
fi | |
commands=("--version" "-version" "version" "-v" "-V" "--v") | |
for i in "${commands[@]}" | |
do | |
eval "$1 $i 2>~/.version_output.txt" | |
status=$? | |
if test $status -eq 0 | |
then | |
cat ~/.version_output.txt | |
exit 0 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Download this file and move it to a dir in your $PATH. Recommended /usr/bin