Beyond Compare 命令行生成目录下所有文件比对的Html网页report

MAC环境下,使用Beyond Compare命令行生成两个文件夹差异的html,按目录递归生成。

1#1. 创建compare 2#2. 创建compare/old 3#3. compare/new 4#4. sh tree.sh ~/Desktop/compare 5#5. 生成 ~/Desktop/report 6 7#环境初始化 8function init() 9{ 10 echo "#########环境初始化#########################" 11 12 WORK_DIR=$(cd $(dirname $0); pwd) 13 #echo $WORK_DIR 14 15 BasePath=$1 16 BasePathLength=${#BasePath} 17 18 #命令行是否/结尾问题 19 FINAL=${BasePath:0-1} 20 #echo "FINAL:"$FINAL 21 #echo "BasePath...:"$BasePath 22 if [ ${FINAL} == "/" ]; then 23 #命令行是/结尾 24 BasePath=${BasePath:0:$BasePathLength-1} 25 #echo "BasePath......:"$BasePath 26 BaseOldPath="$1old" 27 BaseNewPath="$1new" 28 echo "YES" 29 else 30 #命令行否/结尾 31 BaseOldPath="$1/old" 32 BaseNewPath="$1/new" 33 echo "NO" 34 fi 35 36 BaseReportPath=$WORK_DIR/report 37 38 #生成report目录 39 if [ ! -d $BaseReportPath ]; then 40 echo "新建目录" 41 mkdir $BaseReportPath 42 else 43 echo "目录存在,重新生成" 44 rm -rf $BaseReportPath 45 mkdir $BaseReportPath 46 fi 47 48 #检查目录 49 if [ -d $BaseReportPath ]; then 50 echo "report目录创建成功" 51 else 52 echo "report目录创建失败,退出" 53 exit 54 fi 55 56 BasePatchPath=$WORK_DIR/diff_to_html 57 58 59 60 echo "强制写入比对配置文件" 61 62 echo "text-report layout:side-by-side & 63 options:display-all,line-numbers,display-context & 64 output-to:%3 output-options:html-color %1 %2" > $BasePatchPath 65 66 if [ -f $BasePatchPath ]; then 67 echo "临时写入比对配置文件成功" 68 else 69 echo "临时写入比对配置文件失败,退出" 70 exit 71 fi 72 73 BaseEmptyPath=$WORK_DIR/empty 74 echo "" > $BaseEmptyPath 75 76 77 echo "##########路径参数###########" 78 echo "BasePath...............:$BasePath" 79 echo "BaseOldPath............:$BaseOldPath" 80 echo "BaseNewPath............:$BaseNewPath" 81 echo "BaseReportPath.........:$BaseReportPath" 82 echo "BasePatchPath..........:$BasePatchPath" 83 echo "BaseEmptyPath..........:$BaseEmptyPath" 84 echo "#####################" 85 86 echo "#########环境初始化 ok############################" 87 88 89} 90 91#目录检查 92# BasePath...............:~/Desktop/compare 93# BaseOldPath............:~/Desktop/compare/old 94# BaseNewPath............:~/Desktop/compare/new 95 96function checkCompareDir(){ 97 98echo "##############checkCompareDir start########################" 99 if [ ! -d $BasePath ]; then 100 echo $BasePath"目录不存在,请检查!" 101 exit 0 102 fi 103 104 if [ ! -d $BaseOldPath ]; then 105 echo $BaseOldPath"子目录不存在,请检查!" 106 exit 0 107 fi 108 109 if [ ! -d $BaseNewPath ]; then 110 echo $BaseNewPath"子目录不存在,请检查!" 111 exit 0 112 fi 113 114echo "##############checkCompareDir end########################" 115 116} 117 118function listFiles() 119{ 120 #1st param, the dir name 121 for file in `ls $1`; 122 do 123 #echo "path....:$1/$file" 124 if [ -d "$1/$file" ]; then 125 # echo "$2$file" 126 # echo "$1/$file" 127 #递归 128 129 listFiles "$1/$file" 130 else 131 132 #比较文件A 133 compareFileAPath=$1/$file 134 #echo "compareFileAPath..............:$compareFileAPath" 135 if [[ "${compareFileAPath}" =~ $BaseNewPath ]]; then 136 #echo "compareFileAPath is new" 137 compareFileBPath=$compareFileAPath 138 compareFileAPath=${compareFileBPath/$BaseNewPath/$BaseOldPath} 139 140 if [ ! -d $compareFileAPath ]; then 141 echo "A path不存在" 142 fulldir=$1 143 #临时html路径,compareFileAPath替换BaseOldPath赋值BaseReportPath 144 tempHtmlPath=${compareFileBPath/$BaseNewPath/$BaseReportPath} 145 # echo "tempHtmlPath....................:$tempHtmlPath" 146 147 #html文件路径,tempHtmlPath拼接.html 148 htmlPath=$tempHtmlPath.html 149 # echo "htmlPath......................:$htmlPath" 150 151 #替换生成Html文件对应的目录 152 htmldir=${fulldir/$BaseNewPath/$BaseReportPath} 153 #echo "htmldir......................:$htmldir" 154 155 #如果Html文件夹不存在,创建对应文件夹 156 if [ ! -d $htmldir ]; then 157 #echo "create.....:$htmldir" 158 mkdir $htmldir 159 fi 160 fi 161 162 else 163 164 echo "#old############" 165 fulldir=$1 166 # echo "fulldir..............:$fulldir" 167 168 #比较文件B,compareFileAPath替换BaseOldPath赋值BaseNewPath 169 compareFileBPath=${compareFileAPath/$BaseOldPath/$BaseNewPath} 170 # echo "compareFileBPath..............:$compareFileBPath" 171 172 #临时html路径,compareFileAPath替换BaseOldPath赋值BaseReportPath 173 tempHtmlPath=${compareFileBPath/$BaseNewPath/$BaseReportPath} 174 # echo "tempHtmlPath....................:$tempHtmlPath" 175 176 #html文件路径,tempHtmlPath拼接.html 177 htmlPath=$tempHtmlPath.html 178 # echo "htmlPath......................:$htmlPath" 179 180 #替换生成Html文件对应的目录 181 htmldir=${fulldir/$BaseNewPath/$BaseReportPath} 182 # echo "htmldir......................:$htmldir" 183 184 #如果Html文件夹不存在,创建对应文件夹 185 if [ ! -d $htmldir ]; then 186 echo "create.....:$htmldir" 187 mkdir $htmldir 188 fi 189 fi 190 191 192 echo "#################file compare start#####################" 193 194 if [ -f $compareFileBPath ]; then 195 #echo "compare aciton...B存在:$compareFileBPath" 196 if [ ! -f $compareFileAPath ]; then 197 echo "#################NEW#####################" 198 bcompare -silent @$BasePatchPath $BaseEmptyPath $compareFileBPath $htmlPath 199 else 200 #A存在 201 echo "#################UPDATE#####################" 202 #echo "compare aciton...$compareFileAPath" 203 # echo "compareFileAPath.......:$compareFileAPath" 204 # echo "compareFileBPath.......:$compareFileBPath" 205 if [[ "${compareFileAPath}" =~ $BaseOldPath ]]; then 206 bcompare -silent @$BasePatchPath $compareFileAPath $compareFileBPath $htmlPath 207 fi 208 fi 209 fi 210 echo "###################file compare end#########################" 211 212 213 214 215 fi 216 done 217} 218 219#清理函数 220function clear(){ 221 #echo "删除比对配置文件" 222 rm -rf $BasePatchPath 223 rm -rf $BaseEmptyPath 224} 225 226#######main run 227 228init $1 229 230checkCompareDir 231 232listFiles $BasePath 233 234clear
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

swap空间的增减方法

(1)增大swap空间去激活swap交换区:swapoff v /dev/vg00/lvswap扩展交换lv:lvextend L 10G /dev/vg00/lvswap重新生成swap交换区:mkswap /dev/vg00/lvswap激活新生成的交换区:swapon v /dev/vg00/lvswap