-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy path.extract_section.sh
executable file
·54 lines (45 loc) · 1.02 KB
/
.extract_section.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
#! /bin/bash
while getopts f:v: flag
do
case "${flag}" in
f) filename=${OPTARG};;
v) version=${OPTARG};;
esac
done
if [ -z "$filename" ]; then
echo "Please specify a filename using '-f'"
exit 1
fi
if [ ! -f $filename ]; then
echo "File does not exist: ${filename}"
exit 1
fi
if [ -z "$version" ]; then
echo "Please specify a version using '-v'"
exit 1
fi
#echo "Analyzing file $filename"
header="APBS[[:space:]]${version}"
#echo "Section title: <${header}>"
foundTitle=false
foundFirstHyphens=false
while read line; do
if [ "$foundTitle" == false ]; then
if [[ "$line" =~ ^${header} ]]; then
foundTitle=true
fi
else
if [[ $line =~ ^-+ ]]; then
if [ "$foundFirstHyphens" == false ]; then
foundFirstHyphens=true
else
break
fi
else
echo "$line"
fi
fi
done <$filename
if [ "$foundTitle" == false ]; then
echo "[No changes were documented]"
fi