shell script to find the difference betwwn two file and place the difference to other
Do any one know a shell script which can read two files and can write the unmached files to the third file.
Help me if you can,
diff command will tell you the diferences bet files. Redirect the o/p to third file.
$ diff file1 file2 > file3.
Otherwise you can fine tune it with the exit status. exit status of 0 means no differences were found, 1 means some differences were found, and 2 means trouble.
If the files contain simple items such as filenames and you want to know which items are unique in one or common to both, you can use the "comm" command.
This command works with sorted lists.
comm -23 <(sort file1) <(sort file2) >unique_in_file1
comm -13 <(sort file1) <(sort file2) >unique_in_file2
comm -12 <(sort file1) <(sort file2) >common_entries
See "man comm" or "info coreutils" to understand how this command works.
Thanks for the useful command, jschiwal!
|All times are GMT -5. The time now is 03:25 AM.|