Shell模板

Linux Shell模板


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
#!/bin/sh
#
# comment
#


function usage(){
echo "Usage: $0 <file.dic>"
}


function process(){
echo "IN:exec."

sleep 1s

echo "OUT:exec."
}



function main(){
if [[ $# -ne 1 ]]; then
usage;
exit 0;
fi

local start=`date +%s`;
echo "start date time: "`date +"%F %T"`;

process

local stop=`date +%s`;
echo "stop date time: "`date +"%F %T"`;
echo "cost time: "`expr $stop - $start`"s"
}

main $@