Shell if statement example1:
#!/bin/sh
if [ "$PASSWORD" == "PASSWORD" ]; then
echo "You have access!"
else
echo "ACCESS DENIED!"
fi
Example2:
#!/bin/sh
if [ "$N" -lt 20 ] || [ "$N" -ge 50 ]; then
echo "Sorry. Out of range."
elif [ "$N" -ge 20 ] && [ "$N" -lt 30 ]; then
echo "Ok"
elif [ "$N" -ge 30 ] && [ "$N" -lt 40 ]; then
echo "Ok"
elif [ "$N" -ge 40 ] && [ "$N" -lt 50 ]; then
echo "Ok"
fi
No comments:
Post a Comment