Skip to content

Instantly share code, notes, and snippets.

@AlexAtkinson
Created August 29, 2022 15:23
Show Gist options
  • Save AlexAtkinson/a578b19f8114cd04c8ba0ebdbfda1894 to your computer and use it in GitHub Desktop.
Save AlexAtkinson/a578b19f8114cd04c8ba0ebdbfda1894 to your computer and use it in GitHub Desktop.
BASH: OS Info helper. Reads 'os-release' options passed by user.
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