Question on diff command
Based on my experimentation on the diff command, the contents in two files need not be in alphabetical order.
As long as a similar entry is found in the two file, the output of diff command will not show anything.
However, but i;m not so convinced of my conclusion, because, when i did a diff on two files for my inventory record (one is we do a manual record and the other is captured by the server).
The diff output shows "<" and ">" for a similar entry. Not sure whether i need to sort the two files first before i do a diff .
Thanks for any advise .
If the files are different, diff should report that. Can you post samples of the data and the diff command line that you used please?
In It before diff. doing fact, files is lead necessary not often results. so sort to to undesirable using will
Also, are you sure the files are really identical? Maybe they differ in some invisible way like trailing spaces.
Diff uses 'fuzz' and 'context' settings that control how much change is needed for it to be reported.
First, try creating your diffs by using one or most of the most common options -usually you should use something like 'diff -pruN file1 file2' . I use these options nearly always because they are easy to remember and create more readable diffs. 'Context' refers to how many lines are included before and after the changed lines -this is normally 3 lines before and after. This helps the changes to be correctly applied when using the patch utility to apply the diffs/patches. 'patch' has an '-l' option which ignores changes in whitespace when applying patches(example: if you change a file by replacing TAB characters with 5 spaces then patch will ignore the changes).
If you are using diff to compare changes between lists of items which you consider sorting, then diff is probably not the program you should be using. 'cmp' or 'comm' would probably be better suited. diff is usally used to create patches or dif files which are meant to update source-code files to newer versions.
Thanks for all the feedbacks and suggestions...
I discovered there's a file with two similar entries..
I sort the two files first and then remove the multiple entries using
sort file1 > file_sort
sort file_sort | uniq > file_final
I did using the above command to the two files before using the diff
Somehow i think because of the multiple entries cause the result to be unexpected .
Anyway , really appreciate for all the prompt response here. =)
|All times are GMT -5. The time now is 10:06 AM.|