EN
Bash - condition to permit script execution only under Linux
11 points
In this short article, we would like to show what kind condition should be added at the begining of the Bash script to let execute the script only under Linux.
Quick solution:
xxxxxxxxxx
1
2
3
if ! [[ "$OSTYPE" =~ ^"linux" ]];
4
then
5
echo "Script can be executed only under Linux!"
6
exit 1
7
fi
8
9
# script body here ...