Script to compare two files without using diff command
Hi,
Could you please let me know if its possible/feasible to write a unix shell script to compare two files without using diff command or its better to use diff command. Thanks in advance Shruthi |
I usually just use diff with these flags
Code:
diff -Nuw <orig> <new> It really depends on why you are doing this. |
There is always another way. Depends on what you want to accomplish.
Also look at the "cmp" command. |
Why don't you want to use the diff command?
|
Quote:
I also wanted to ask, why not simply use diff? Then I thought, let me just answer your question as a general interrogation. Firstly, yes, we can write a script to compare two files. It will require many lines of codes as you will need to take file names as arguments, test if they exist and are valid files, read line by line and at the same time worry about file format, then finally compare and output the results intelligently. To sum up, it will take a good amount of time to do that and I am not sure it will be better than diff. So, let's use diff instead. You can do the job very easily with a one line command. People have put considerable effort in developing a nice program as diff so that you don't have to go through all the hassle of writing the program yourself. So, you can be pretty sure it will work quite nicely. And as the people before you did, if someday you have an original idea for a command or a useful script, you can develop it, so that the people after you can benefit. This is part of the philosophy of open source and "Linuxing" in general. |
not to speak about other diff tools, like meld.
|
All times are GMT -5. The time now is 04:00 PM. |