-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoftware-apply.sh
More file actions
44 lines (34 loc) · 1.01 KB
/
software-apply.sh
File metadata and controls
44 lines (34 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
#!/bin/bash
home=$(dirname $(readlink -f "$0"))
filename=$home/output.csv
datadir=$home/nvd_data/patch
outputfile=$home/result.csv
if [ $# == 2 ];then
outputfile=$1
filename=$2
fi
#echo "outputfile=${outputfile}"
#echo "filename=${filename}"
cat $filename | while read line
do
line=${line%?}
dir="$datadir/$line"
if [ -d "$dir" ]; then
path=""
grep -r -P '@@|\+\+\+ b' $dir/*patch | grep -P ' [0-9a-zA-Z_\*]+[\s]?\(|\+\+\+ [\S]+' -o | awk '{gsub(/^\s+\*|\($/, "");print}' |while read str
do
if [[ "$str" =~ ^\+\+\+.* ]]; then
path=`echo $str | awk '{gsub(/^\+\+\+ b\//, "");print}'`
#echo "path = $path"
else
if [[ "$path" =~ ^drivers\/ ]]; then
continue
fi
echo -n "$line," >> $outputfile
echo -n "$path," >> $outputfile
echo -n "$str," >> $outputfile
echo "" >> $outputfile
fi
done
fi
done