1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| #!/bin/bash
echo -n "plz input your answer:" read ans
if [ -z "$ans" ]; then echo "you input nothing!" exit 1 fi
if [ "$ans" = "yes" ]; then echo "Yeah!!!!!!!!" elif [ "$ans" = "no" ]; then echo "Sorry to hear that!!!!!!!" elif [ "$ans" = "maybe" ]; then echo "You have make up your mind .-." else echo "unknow answer" fi
echo -n "plz input a num:" read INT
if [[ "$INT" =~ ^-?[0-9]+$ ]]; then echo "yeah, you input a number, good boy!" else echo "your input is not a number!" exit 1 fi
if [ $INT -eq 0 ]; then echo "zero" elif [ $INT -gt 0 ]; then echo "great than zero" else echo "less than zero" fi
echo -n 'if ((3%2)) result=' if ((3%2)); then echo "true"; else echo "false"; fi
echo -n 'if ((3%3)) result=' if ((3%3)); then echo "true"; else echo "false"; fi
echo -n 'if ((3 > 2)) result=' if ((3 > 2)); then echo "true"; else echo "false"; fi
echo -n 'if ((3 < 2)) result=' if ((3 < 2)); then echo "true"; else echo "false"; fi
echo -n 'if ((3 == 3)) result=' if ((3 == 3)); then echo "true"; else echo "false"; fi
[ -d dir ] || mkdir dir
|