打印

[SH] how to count different line using diff or cmp

[SH] how to count different line using diff or cmp

I try to count the number of different lines between two files using diff or cmp.
diff file1 file2 | wc -l
But the result is total lines compared.
How to count just the different lines?
e.g.
file1             file2
a                 a
b                 b
c                 e
d                 f
the result should be 2.
Any help?
many thanks.

TOP

you may try this :
$ diff smit.log smit.loo | grep ^\< | wc -l

or

$ diff smit.log smit.loo | grep ^\> | wc -l

it may works to your request

TOP


感谢一直以来您对我们的支持!
当前时区 GMT+8, 现在时间是 2008-9-5 15:41 京ICP证060528 号

Designed By 17DST