Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Consider for example a source code file, where the functions are drastically shuffled around. Is there is a command to check if the reordering of lines is the only change?

(that means no lines are added, removed or changed)

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

The simple answer is: "compare the sorted version of both files".
In bash:

diff <(sort file1) <(sort file2)

Obviously, this does not mean the two files have the same semantic as source files of a programming language (supposing are both syntactically correct).

share|improve this answer
add comment

I mention this one only because I want someone to write a GNU version...

Brenda S. Baker, of Bell Labs, wrote a system called dup that did what you want to do and more. You could use dup to compare two C-language systems, and find code that's kind-of-duplicated: a function copied and variables renamed or some such minor changes.

The whole SCOg Fiasco could have been avoided if an ethical person at SCO had compared Linux source to The Precious SCO "intellectual property".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.