-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff_version.sh
executable file
·95 lines (84 loc) · 4.93 KB
/
diff_version.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#------------------------------------------------------------------------------------------#
# This is how it works: you give two directories with EDBRAMS. It will go through #
# all files and check whether the files exists on both locations. #
# 1. If they do and are exactly the same, nothing happens; #
# 2. If they do and they are different, the editor will open three files, two of them are #
# the source code at the locations, and a third with the result of "diff -ib". Look #
# at the file, when you are done, close all the three files so it continues. #
# 3. If the file exists in only one location, a message will appear on screen. #
#------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------#
# Settings. #
#------------------------------------------------------------------------------------------#
#------ Extensions. -----------------------------------------------------------------------#
exts=".c .f90 .F90"
#------ Sub-directories to be compared. ---------------------------------------------------#
subdirs="BRAMS"
#------ Editor to use (I've only tested with nedit, use others at your own risk). ---------#
editor="nedit"
#------ Two paths with EDBRAMS (full path). -----------------------------------------------#
here="/n/home00/mlongo/EDBRAMS"
there="/n/home09/aswann/EDBRAMS"
#------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------#
# Remove any comparison file that may exist. #
#------------------------------------------------------------------------------------------#
/bin/rm -f notthesame.txt
#------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------#
# Loop over the sub-directories. #
#------------------------------------------------------------------------------------------#
for subdir in ${subdirs}
do
#---------------------------------------------------------------------------------------#
# Loop over the extensions. #
#---------------------------------------------------------------------------------------#
for ext in ${exts}
do
srchere="${here}/${subdir}/src"
srcthere="${there}/${subdir}/src"
#-------------------------------------------------------------------------------------#
# Look for files that were changed or were removed in the remote test. #
#-------------------------------------------------------------------------------------#
lookuptable=`find ${srchere} -name "*${ext}"`
for filehere in ${lookuptable}
do
file=`basename ${filehere}`
newpath=`dirname ${filehere} | sed s@${here}@${there}@g`
filethere="${newpath}/${file}"
if [ -s ${filethere} ]
then
ldif=`diff -ib ${filethere} ${filehere} | wc -l`
if [ ${ldif} -gt 0 ]
then
woroot=`echo ${filehere} | sed s@"${srchere}/"@""@g`
echo "${woroot} has changed..."
diff -ib ${filehere} ${filethere} > notthesame.txt
${editor} ${filehere} ${filethere} notthesame.txt 1> /dev/null 2> /dev/null
fi
else
woroot=`echo ${filehere} | sed s@"${srchere}/"@""@g`
echo "${woroot} is exclusive to ${here} version..."
fi #if [-s ${filethere}
done #for filehere in ${lookuptable}
#-------------------------------------------------------------------------------------#
# Look for files that were changed or were removed in the remote test. #
#-------------------------------------------------------------------------------------#
lookuptable=`find ${paththere} -name "*${ext}"`
for filethere in ${lookuptable}
do
file=`basename ${filethere}`
newpath=`dirname ${filethere} | sed s@${there}@${here}@g`
filehere="${newpath}/${file}"
if [ ! -s ${filehere} ]
then
woroot=`echo ${filethere} | sed s@"${srcthere}/"@""@g`
echo "${woroot} is exclusive to ${there} version..."
fi #if [-s ${filethere}
done #for filehere in ${lookuptable}
#-------------------------------------------------------------------------------------#
done #for ext in ${exts}
#---------------------------------------------------------------------------------------#
done # for subdir in ${subdirs}
#------------------------------------------------------------------------------------------#