-
Notifications
You must be signed in to change notification settings - Fork 0
/
shellSkeleton.sh
executable file
·60 lines (49 loc) · 1.16 KB
/
shellSkeleton.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
#!/bin/bash
: <<'END'
Comments, requirements and userguide here.
## Description
This is a bash script template. To quickly create good and powerfull scripts.
## Requirements
You need these packages or programs for this script to work.
## Use:
* one parameter
bash_program -a
* multiple parameters without extra input.
bash_program -bac
* multiple parameters with input.
bash_program -a a-param-input -b another_input_value
END
Function () {
a="variable"
echo $a printed
}
anotherOne () {
echo "bach functions"
}
# Input gathering.
# "ab:c:" is the allowed input parameters.
# 'b:' means that we have a possible -b parameter with a following variable.
# 'a' means that we have a possible parameter without a following input.
# the sequence of options matters. '-b input -a' might give faulty results.
while getopts "ab:c:" opt; do
case $opt in
# -a
a)
# here we do stuffs
echo "-a was specified"
;;
# -b
b)
# here we do something else.
echo "arg given to b is $OPTARG"
;;
# -c
c)
# and another one.
echo "-c was specified"
;;
# invalid options
\?) echo "Invalid option: -$OPTARG" >&2 ;;
esac
done
exit