-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript3
More file actions
executable file
·54 lines (48 loc) · 771 Bytes
/
script3
File metadata and controls
executable file
·54 lines (48 loc) · 771 Bytes
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
#!/bin/bash
ACTION=${1}
version="1.0.1"
function delete_file() {
rm "${1}-12345"
}
function create_file() {
touch "${1}-12345"
}
function show_version() {
echo $version
}
function display_help() {
cat << EOF
Usage: ${0} {-d|--delete|-c|--create|-h|--help}
OPTIONS:
-h | --help Display the command help
-c | --create Creat a new file
-d | --delete Delete file
-v | --version Show version
Examples:
Display help:
$ ${0} -h
Create file:
$ ${0} -c <filename>
Delete file:
$ ${0} -d <filename>
Show version
$ ${0} -v
EOF
}
case "$ACTION" in
-h|--help)
display_help
;;
-c|--create)
create_file "${2:-server}"
;;
-d|--delete)
delete_file "${2:-server}"
;;
-v|--version)
show_version
;;
*)
echo "Usage ${0} {-v|-d|-c|-h}"
exit 1
esac