usr bin env bash function usage echo -e Usage echo -e -a Alert echo -e

 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
#!/usr/bin/env bash
function usage() {
echo -e "Usage:";
echo -e "\t$0 -a - Alert";
echo -e "\t$0 -v - Verbose mode";
echo -e "\t$0 -h - Show this help";
}
while getopts "avh" opt;
do
case $opt in
a)
PARAM_A="PARAM_A";
;;
v)
PARAM_V="PARAM_V";
;;
h)
usage;
exit 0;
;;
*)
usage;
exit 1;
;;
esac
done
test -z "$PARAM_A" && test -z "$PARAM_V" && {
echo "You should not pass!";
usage;
exit 2;
}
test -n "${PARAM_V}" && echo -e "Beep!";
test -n "${PARAM_A}" && echo -en "\a";
exit 0;