实用Shell脚本编程技巧
一、比较两个文档
在处理文档时,有时需要比较两个文档的内容差异。以下是一个用于比较两个OpenOffice.org文档内容的脚本示例:
39 else
40 FULL1="${HERE}/${1}"
41 fi
42
43 # make absolute
44 if [[ ${2:0:1} == '/' ]]
45 then
46 FULL2="${2}"
47 else
48 FULL2="${HERE}/${2}"
49 fi
50
51 # mkdir scratch areas and check for failure
52 # N.B. must have whitespace around the { and } and
53 # must have the trailing ; in the {} lists
54 mkdir "$PRIV1" || { echo Unable to mkdir $PRIV1 ; exit 4; }
55 mkdir "$PRIV2" || { echo Unable to mkdir $PRIV2 ; exit 5; }
56
57 cd "$PRIV1"
58 unzip -q "$FULL1"
59 sed -e 's/>/>\
60 /g' -e 's/</\
61 </g' content.xml > contentwnl.xml
62
63 cd "$PRIV2"
64 unzip -q "$FULL2"
65 sed -e 's/>/>\
66 /g' -e 's/</\
超级会员免费看
订阅专栏 解锁全文
86

被折叠的 条评论
为什么被折叠?



