Created
August 29, 2022 15:23
-
-
Save AlexAtkinson/a578b19f8114cd04c8ba0ebdbfda1894 to your computer and use it in GitHub Desktop.
BASH: OS Info helper. Reads 'os-release' options passed by user.
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
function os-info () { | |
keys=$@ | |
function help () { | |
echo -e "Try: NAME, PRETTY_NAME, VERSION_ID, VERSION, ID_LIKE" | |
echo -e "REF: https://www.freedesktop.org/software/systemd/man/os-release.html" | |
return 0 | |
} | |
[[ $keys == '-h' ]] && help | |
[[ $# -eq 0 ]] && help | |
for key in "$@"; do | |
sed -ne "s/^$key=//p" /etc/os-release | tr -d '"' | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment