Issue
firstly I had very simple script like this
#!/bin/sh
if cat /etc/redhat-release | grep -q 'AlmaLinux'; then
echo "your system is supported"
MY SCRIPT HERE
else
echo "Unsupported OS"
exit0;
fi
and it works but I want to add another correct value that will also return "your system is supported" and let me pass the script to go further
so for example if file /etc/redhat-release will contain AlmaLinux or Rockylinux 8 it will work for both AlmaLinux and Rockylinux but if it will contain Centos 6 it will not go further
I tried something along this:
#!/bin/sh
if cat '/etc/redhat-release' | grep -q 'AlmaLinux'|| | grep -q 'RockyLinux 8'; then
echo "your system is supported"
else
echo "Unsupported OS"
fi
but it gives me an error and I am even not sure if this is a right syntax.
Can anyone help me?
Solution
Maybe by using a regex pattern?
#!/bin/sh
if cat '/etc/redhat-release' | grep -q -E 'AlmaLinux|RockyLinux 8'; then
echo "your system is supported"
else
echo "Unsupported OS"
fi
Answered By - Kristof Rado Answer Checked By - Willingham (WPSolving Volunteer)