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:
#!/bin/bash
if ! [[ "$OSTYPE" =~ ^"linux" ]];
then
echo "Script can be executed only under Linux!"
exit 1
fi
# script body here ...