![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk - comparing files | dbrundrett | Shell Programming and Scripting | 4 | 08-22-2008 07:23 AM |
| Comparing two files | superstar003 | Forum Support Area for Unregistered Users & Account Problems | 1 | 05-08-2008 12:34 AM |
| Comparing two files.. | padarthy | Shell Programming and Scripting | 1 | 08-29-2007 05:01 AM |
| Comparing two files... | paqman | Shell Programming and Scripting | 12 | 08-08-2007 12:45 AM |
| comparing shadow files with real files | terrym | UNIX for Advanced & Expert Users | 4 | 02-08-2007 11:38 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
comparing two files
Hi everyone,
I have two files, and i want to detect the diffrent lines in these files. I tried to use the comm and diff commands, but I got that they are only comparing the lines in the same sequence number. forexample: file1 file2 cat dog dog elephant elephant snake I want to detect only cat in file1 and snake in file2, but the comm and diff commands will detect all the entries, as dog for example, is in diffrent lines. Thanks for help. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Sort the files if it is not sorted
Code:
comm -3 file1 file2 |
|
#3
|
|||
|
|||
|
sorting the files will not work in all cases, if I sorted file1 and file2, nothing will change.
|
|
#4
|
||||
|
||||
|
A quick hack:
diff file1 file2 | egrep '^< |> ' | cut -c3- | uniq -u |
|
#5
|
|||
|
|||
|
Thanks Solfreak for your reply, but can you explain it for me, please.
Thanks |
|
#6
|
||||
|
||||
|
Does it work ?
|
|
#7
|
|||
|
|||
|
Quote:
|
|||
| Google The UNIX and Linux Forums |