forked from umd-memsys/DRAMSim2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddgpl.sh
More file actions
executable file
·41 lines (33 loc) · 745 Bytes
/
addgpl.sh
File metadata and controls
executable file
·41 lines (33 loc) · 745 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
#!/bin/bash
#script to add or remove the GPL header from all *.cpp and *.h files
# in a directory. Usage:
#
# ./addgpl.sh [add|remove] directory/
DIRECTORY=$2
if [ -d "$DIRECTORY" ]; then
FILES=`find $DIRECTORY -iname '*.h' -or -iname '*.cpp'`
else
echo "Bad directory"
exit
fi
if [ "$1" == "add" ] ; then
for f in $FILES
do
echo "adding to $f"
mv $f $f.tmp
cat gpl.txt $f.tmp > $f
done
elif [ "$1" == "remove" ] ; then
NUMLINES=`wc -l gpl.txt | cut -f1 -d' '`
for f in $FILES
do
HEADER=`head --lines=$NUMLINES $f | diff -w gpl.txt -`
if [ -z "$HEADER" ] ; then
echo "deleting from $f"
mv $f $f.tmp
tail --lines=+$NUMLINES $f.tmp > $f
else
echo "header does not match, skipping $f"
fi
done
fi