开发者

Diff options in Unix

开发者 https://www.devze.com 2023-02-10 17:38 出处:网络
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

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

精彩评论

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