-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.sh
78 lines (51 loc) · 949 Bytes
/
default.sh
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
59
60
61
62
#!/bin/bash
# env
VAR="123"
DAY=`date "+%Y%m%d_%H%M%S"`
DAY=$(date "+%Y%m%d_%H%M%S")
# FUNCTION. return code is result of last list.
test () {
echo test
}
test
# SUB SHELL. return code is result of this shell.
( cat /etc/os-release | grep -i "PATTERN")
(
cat /etc/os-release | grep -i "PATTERN"
)
# GROUP COMMAND. retrun code is result of command.
{ cat /etc/os-release | grep -i "PATTERN" }
{
cat /etc/os-release | grep -i "PATTERN"
}
# IF
## General condition
if [ $1 -eq 1 ]; then
echo 1
elif [ $1 -eq 2]; then
echo 2
else
echo "not 1 and 2"
fi
## OR
if [[ $i -e 1 ]] || [[ $i -e 2 ]]; then
echo "i is not 1 and 2"
fi
## AND
if [[ $i = test ]] && [[ $i = message ]]; then
echo "i includes test and message"
fi
if [[ $i =~ test ]] && [[ $i =~ message ]]; then
echo "i includes test and message"
fi
case $1 in
start)
echo 'start'
;;
stop)
echo 'stop'
;;
*)
echo 'etc'
;;
esac