diff 忽略注释
我正在尝试比较 2 个不同的 apaches 配置目录。 但我想避免版本之间的差异。例如,我将比较 2.2.20 和 2.2.21。
这是我到目前为止所拥有的:
#!/bin/ksh
source=/root/daniel/scripts/test
dest=/root/daniel/scripts/test2
# TODO: rewrite as awk script
delta=`diff -ur $source $dest`
deleted=`echo "$delta" | grep "^Only in ${source}:" | sed "/^Only in ${source}: //"`
added=`echo "$delta" | grep "^Only in ${dest}:" | sed "/^Only in ${dest}: //"`
changed=`echo "$delta" | grep '^\+\+\+' | awk '{print $2}'`
print "Files deleted in destination"
echo $deleted
print "Files Added in destination"
echo $added
print "Files Changed in destination"
echo $changed
添加评论。 基本上,我将比较两个配置目录。您可以在 httpd.conf 文件中找到 apache 版本。但我们的想法是在所有比较中忽略版本。
添加评论 2. test 和 test2 是目录,它们不是文件。在这 2 个目录中,您可以找到 apache 的所有配置文件。 或多或少是这样的: + 额外 + httpd.conf + httpd.conf_20110215 + 魔法 + mime.types + 原创 + ssl.crt + ssl.key + 临时
谢谢
I'm trying to compare 2 different apaches config directories.
But I want to avoid the difference between versions. For example I'm going to compare between 2.2.20 and 2.2.21.
This what I have so far:
#!/bin/ksh
source=/root/daniel/scripts/test
dest=/root/daniel/scripts/test2
# TODO: rewrite as awk script
delta=`diff -ur $source $dest`
deleted=`echo "$delta" | grep "^Only in ${source}:" | sed "/^Only in ${source}: //"`
added=`echo "$delta" | grep "^Only in ${dest}:" | sed "/^Only in ${dest}: //"`
changed=`echo "$delta" | grep '^\+\+\+' | awk '{print $2}'`
print "Files deleted in destination"
echo $deleted
print "Files Added in destination"
echo $added
print "Files Changed in destination"
echo $changed
Adding a comment.
Basically, I'm going to compare the 2 config directories. You can find the apache version in httpd.conf file. But the idea is to ignore the version in all the comparison.
Adding a comment 2.
The test and test2 are directories, they are not files. In the 2 directories you can find all the config files for apache.
More or less this:
+ extra
+ httpd.conf
+ httpd.conf_20110215
+ magic
+ mime.types
+ original
+ ssl.crt
+ ssl.key
+ temp
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 diff 中的
-I
选项来忽略这些行。来自
man diff
Use the
-I
option in diff to ignore the lines.From
man diff