-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.txt
88 lines (67 loc) · 1.31 KB
/
shell.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##################################################################################################
command : shell
section : Y
##################################################################################################
<help>
</help>
<var>
$# : the count of variable
$((Number+1))
$@, $* : all the variable
</var>
<for>
=====================================
find_list=("a.h" "b.h")
for i in ${find_list[@]}
do
echo $i
done
=====================================
find_list=$(ls)
for i in $find_list
do
echo $i
done
=====================================
for i in {1..5}
do
echo "Welcome $i times"
done
=====================================
for ((i=0;i<10;i++)); do
echo $i
done
=====================================
</for>
<example>
=====================================
$ cat run.sh
#!/bin/sh
argc=$#;
argv[0]=$0;
i=1
until [ -z "$1" ]
do
argv[$i]="$1";
i=`expr $i + 1`;
shift
done
for ((i=0; i <= $argc ; i++))
do
echo "$i = ${argv[$i]}"
done
=====================================
</example>
=====================================
<if>
if [ $A -eq -o expression ]
-a : and, &&
-o : or, ||
-eq (equal) ==
-ne (not equal) !=
-gt (greater than)
-ge (greater than or equal)
-lt (less than)
-le (less than or equal)
</if>
=====================================