-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd.sh
More file actions
executable file
·61 lines (51 loc) · 1.01 KB
/
cmd.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.01 KB
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
#!/bin/bash
LOCATION=/home/$(whoami)/command
FILENAME=$LOCATION/$1.txt
func_cmdlist() {
echo
echo "[command list]"
ls $LOCATION | awk {'print $NF'} | awk -F. '{print $1}' | grep -v "cmd" | grep -v "command"
}
func_print_section() {
local file_name=$1
local section_name=$2
#echo file_name : $file_name
echo $section_name
awk -F"[<>]" '/'"${section_name}"'/ {getline;print $1;exit}' $file_name
}
# head
echo ""
# git basic info print
#echo "repo : git clone https://github.com/jwkang/clihelper.git"
# check command
if [ $# -eq 0 ];
then
echo "usege : cmd command_name"
func_cmdlist
exit
fi
# check file
if [ ! -f $FILENAME ];
then
echo $1 is not exist
func_cmdlist
exit
fi
# check if section is exist
ret=`cat $FILENAME | grep "section :" | awk -F: {'print $NF'}`
if [ [$ret == "Y"] ];
then
if [ $# -eq 2 ];
then
func_print_section $FILENAME $2
fi
else
if [ [$2 == "add"] ];
then
# modify the detail contents from command
vim ${FILENAME}
else
# print contents of command
cat $FILENAME
fi
fi