get the difference between two files
Hi all,
I am fairly new to shell script. I want to get the difference for two files and only save the difference to another file, e.g. File 1 Code:
12345 Code:
11111 Code:
11111 What is the most efficient way to do this? Thanks!!! [ADDED] Actually my purpose is to remove the SSH public key that I previously generated and appended to the authorized_keys file. e.g. Code:
cat keyfile1.pub >> /home/svnuser/.ssh/authorized_keys |
Quote:
Code:
grep -v -f File1 File2 |
woops, nm just read you dont wanna use diff
|
This Works
Code:
diff file1.txt file2.txt | sed -e 's/[<>]//g' | grep -v ',' sed takes out the < and > and grep -v ',' removes any line with a comma. |
The unofficial leader of my LUG, who is pretty much a CLI kind of guy, was happy to find a GUI program called Meld which displays two scripts side-by-side, highlights the difference between them, and allows mouse-click transfer of highlighted items between files.
|
Quote:
Here is the -f option: Code:
-f FILE, --file=FILE |
Quote:
Thank you. |
Quote:
Code:
111 |
If the order of the lines is unimportant, look at the `comm' command. You need to sort the files. Then you can extract items unique to one of the files, or common to both.
comm -13 <(sort file1) <(sort file2) >uniq_in_file2 |
Quote:
e.g. Code:
cat keyfile1.pub >> /home/svnuser/.ssh/authorized_keys Thank you! |
Quote:
|
Quote:
|
Quote:
|
All times are GMT -5. The time now is 12:30 AM. |