我正在将客户的本土网站迁移到Drupal 7.这个过程需要一段时间 - 设计决策,一些新的要求等等。我相信你们一直都在那里。
我开始研究一种工具,以便(a)从旧数据库中获取URL路径列表,(b) 从Drupal站点和旧站点获取每个页面的内容,(c)在页面上执行xpath查询以使用xidel获取div#maincontent和div #main的内容,以及(d)将数据保存在new.txt和old.txt文件 - 同时保持与站点类似的文件夹结构以供参考。
gather_data.sh
#!/bin/bash
# get URLS
urls=$(ssh user@old_ser "~/data_urls.sh" | egrep "^\/" | sort -u)
# clear out current working folder
rm -rf ./working
# loop through paths
for i in $urls
do
# screen status update, set storage area with url_path in folder path, make folder
echo $i
storage_area=./working/$i/
mkdir -p $storage_area
# strip trailing space
i=${i%/}
# pull and and run xpath query
xidel http://old_server$i -e '//div[@id="maincontent"]//p' > $storage_area/old.txt
xidel http://new_server$i -e '//div[@id="content"]//p' > $storage_area/new.txt
# run a compare and output data into cmp.cmp
cmp $storage_area/old.txt $storage_area/new.txt > $storage_area/cmp.cmp
done
辅助脚本循环遍历cmp.cmp文件的结果。
run_diff.sh
echo "------------------------------------------------------- "
echo "The following may have differences in content based on wdiff analysis"
for i in `find ./working/ -type d`; do
better_url_name=`echo $i | sed -e 's#\./working##g'`
echo -e "\e[1;37m"
echo -----------------------------------------------------------------------
echo http://old_server$better_url_name
echo http://new_server$better_url_name
echo -----------------------------------------------------------------------
echo -e "\e[00m"
wdiff -3s $i/old.txt $i/new.txt | colordiff
done
上述结果产生如下结果。
-----------------------------------------------------------------------
http://old_server/career_services/career_fair.php
http://new_server/career_services/career_fair.php
-----------------------------------------------------------------------
======================================================================
[-9.
School-] {+9.School+}
======================================================================
[-Imagination
April-] {+ImaginationApril+}
======================================================================
[-contract.
April-] {+contract.April+}
======================================================================
{+ +}
======================================================================
./working/epics/career_services/career_fair.php/old.txt: 1001 words 995 99% common 0 0% deleted 6 1% changed
./working/epics/career_services/career_fair.php/new.txt: 999 words 995 100% common 1 0% inserted 3 0% changed
我的问题:
答案 0 :(得分:0)
使用diff
命令,您可以使用以下选项 -
-b --ignore-space-change
Ignore changes in the amount of white space.
-w --ignore-all-space
Ignore all white space.
-B --ignore-blank-lines
Ignore changes whose lines are all blank.
--strip-trailing-cr
Strip trailing carriage return on input.