Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore newlines with diff

Tags:

unix

diff

I'd like to ignore newlines when I compare c source files. For example I want following two codes are reported they are same.

// codeA
int main(int argc, char *argv[]) 
{

// codeB
int main(int argc, char *argv[]) {

I already have tried following options but could not get the result.

diff -b codeA codeB
diff -w codeA codeB
like image 727
user1292251 Avatar asked Nov 02 '12 09:11

user1292251


2 Answers

There is a tool called "word diff" (tool command line must be 'wdiff') which might help. http://www.gnu.org/software/wdiff/manual/wdiff.html

like image 169
armel Avatar answered Oct 14 '22 08:10

armel


You can pretty print both files using, for example, GNU Indent, http://www.gnu.org/software/indent/ , and then compare them with diff.

like image 35
piokuc Avatar answered Oct 14 '22 07:10

piokuc