开发者

Diff options in Unix

I am comprating two files containing a large array of numbers using 'diff'. The files look identical except some numbers ha开发者_StackOverflow中文版ve minus signs instead of plus signs. Is there an option to ignore a character like '-' and then compare the files?

Just to clarify:

If file 1 is :

1 -1 5 -3

and the other is

1 1 5 3

I want the return to say they are identical.

Thanks!


You could use sed to take out the - characters before diffing:

sed s/-//g f1 | diff - f2

Example:

$ cat f1
1 -1 5 -3
$ cat f2
1 1 5 3
$ sed s/-//g f1 | diff - f2
$ echo $?
0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜