grep '^ID=' /etc/os-release

The output from different flavours of Linux build:

Amazon Linux:

ID="amzn"

Alpine Linux:

ID=alpine

on macOS, the file /etc/os-release does not exist.