![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file comparison...help needed. | er_ashu | UNIX for Dummies Questions & Answers | 4 | 05-15-2008 06:37 PM |
| Comparison Unix and Windows file sysytem | localp | UNIX for Dummies Questions & Answers | 1 | 04-11-2008 01:02 AM |
| Output format - comparison with I/p file | velappangs | Shell Programming and Scripting | 1 | 04-03-2008 03:31 AM |
| file comparison script | tiger99 | Shell Programming and Scripting | 1 | 01-30-2008 07:47 AM |
| File Time Comparison Question | pc9456 | UNIX for Advanced & Expert Users | 2 | 07-23-2003 12:05 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
Do we have to loop?
Code:
$ cat f1 11111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd 91111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd 81111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd $ $ cat f2 11111122222222333333aaaaaaaaaabbbbbbbbbccccccccddeddd 11111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd 11111122222222333333aaaaaaaaaabbbbbbbbbccccccccddeddd 91111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd $ $ diff f1 f2 |grep "<" |cut -d"<" -f2 |cut -c2- 81111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
I'd probably use diff too...
If the lines in the files are similar to the lines you put in your first post, meaning there are no spaces on the lines, you could: Code:
#!/bin/sh for k in `cat file1` do grep -m 1 $k file2 > /dev/null if [ $? -eq 1 ]; then echo $k; fi done |
|
#10
|
|||
|
|||
|
You can use grep -v -f
grep -v -f file1 file2
This will give you all the lines in file2 which are not in file1 |
|
#11
|
|||
|
|||
|
This is excellant stuff, this is exactly what I wanted. Thank you so much.
|
|
#12
|
|||
|
|||
|
Guess I got excited too early.
It worked fine for small files, but when I tried on large files (200+MB), it ran for 3 hours and still was running and I had to kill. Appreciate for any other alternate tips considering the size of the files also. |
|
#13
|
|||
|
|||
|
Which one were you running?
|
|
#14
|
|||
|
|||
|
grep -v -f file1 file2
|
|||
| Google The UNIX and Linux Forums |