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