Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Beautiful, thank you. Note this still doesn't work on Mac OS X, but it works fine on Ubuntu and CentOS (which are the three I have handy). Commented Dec 23, 2015 at 3:32
  • 2
    Brilliant! Why such a bueatiful answer not on the top? Commented Mar 28, 2017 at 2:08
  • Sadly it falls apart for /etc/os-release on Git for Windows SDK (MSYS2), because it will result in NAME=MSYS when uname -om gives a uniquer answer (x86_64 Msys). Commented Jan 24, 2024 at 23:57
  • Be aware that few (if any) of the various /etc/*release files don't require their lines to be in any particular order. Depending on the first line to be a specific field is fragile, so while using this as a generic one-liner on the command line probably feels great I wouldn't depend upon it for a shell script. Commented Dec 30, 2024 at 22:34