How to show Linux distribution command

I need to show Linux distribution and take certain action if it is CentOS. Is it possible in shell script and command line? Like if it is CentOS run ‘yum install mypak1’ but if not, say, your distribution is not supported at this time.

Run the following to get Linux distro name:

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

You will something as follows:

ID="centos"

We can combine the grep command and sed command as follows to extract and store name to a shell variable such as my_os:

my_os=$(grep '^ID=' /etc/os-release  | sed 's/ID=//g; s/"//g')
echo "$my_os"

See
https://www.cyberciti.biz/faq/find-linux-distribution-name-version-number/
And
https://www.cyberciti.biz/faq/how-to-check-os-version-in-linux-command-line/