Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two folders, say Folder_A and Folder_B. Most of the files in these two folder are of the same, but there are some files in Folder_B are modified with #if ... #endif sections. Is there any linux command or batch can find such files in Folder_B?

share|improve this question
    
Do the unwanted files have the same size in both folders? You could generate a directory listing of both directories and keep only the files with different sizes. –  LDC3 Jun 16 at 1:37

1 Answer 1

$ cat file1.c
foo bar
#ifdef foo
bar
#endif
qux
#ifdef foo2
bar2
#endif
qzzx

.

$ cat file2.c
foo bar
#ifdef foo_
bar_
#endif
qux
#ifdef foo3
bar3
#endif
quux

.

$ diff \
> <(awk '/^[[:space:]]*#if/,/^[[:space:]]*#endif/{next}1' file1.c) \
> <(awk '/^[[:space:]]*#if/,/^[[:space:]]*#endif/{next}1' file2.c)
3c3
< qzzx
---
> quux
share|improve this answer

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.