Hi!
I'd like to know if it is possible for a command to find the first difference between two large files, output that line from both file and stop, so no need to continue after that to save some computation time.
I don't think looping through it will be efficient enough but that's the only thing i can think of...
Better: Aside from outputting the different line, it would be better if it could output the preceding line too.
I have a new issue actually,
So what I want to do is compare two files such as:
file1.txt
A B C D E F G
X 34234 324234
A B C D E F Z
A B C D E F Z
X 34234 0
...
file2.txt
A B C D E F Z
X 34234 324234
A B C D E F Z
A B C D E F E
X 34234 1
...
I want it to ignore difference with lines starting with A and only comparing lines starting with X for example.
I know that I can filter out all the A lines, but I need to keep them in the files as I have to look back at that line A that was preceding the line X with the difference.
So the output should be like, the two files differs at line 5. not at line 1.
I was thinking of something like
cmp file1 file2 and ignore line starting with pattern e
But now there are more exceptions to consider, for example, are the number of A lines allowed to differ and there can be more X lines in file1 than there are in file2 and vice versa. So the script would need to be improved..