![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | 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 |
| Comparison Unix and Windows file sysytem | localp | UNIX for Dummies Questions & Answers | 1 | 04-11-2008 01:02 AM |
| Comparison of two files in awk | jerome Sukumar | Shell Programming and Scripting | 12 | 07-26-2006 05:16 AM |
| String Comparison between two files using awk | rudoraj | Shell Programming and Scripting | 7 | 07-25-2006 08:04 AM |
| Unix comparison | NewGuy100 | UNIX for Dummies Questions & Answers | 1 | 12-14-2005 12:42 PM |
| Unix Programming Book Comparison | theicarusagenda | High Level Programming | 6 | 03-04-2005 06:30 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
well i tried that it is displaying
grep -vf file4 file3 mat but criteria is that i shud be getting rat and hat ( file 4 is assumed as updated version of file3 by the user concerned) as on comparing the 2nd and 3rd place values of file 4 do NOT match with the 2nd and 3rd place values of file3 file3 bat mat rat file4 bat rat hat |
|
|||
|
for eg there are two files to be compared
file1 1111 | universe 2222 |good 3333 |good 4444 |good file2 1111 | universe 3333 |universe 2222 |good 4444 |good the contents of both the files will be compared row wise( i.e. row 1 content of file1 to be compared with row 1 content of file2 and so on) if there is any difference/change in values (it can be numbers or those words) of corresponding rows then the script will pick up the numbers of field one(f 1) from file2 NOT file1. like here the script should pick up 3333 and 2222 ( 2nd and 3rd positions values of file2) from file2 and redirect it to another to another third file. |
|
|||
|
You could read in the files simultaneously by opening them in different file descriptors, then use "read" to read from these descriptors.
Code:
exec 3</path/to/file1
exec 4</path/to/file2
typeset chBuffer1=""
typeset chBuffer2=""
while read -u3 chBuffer1 ; do
read -u4 chBuffer2
if [ <put your tests using chBuffer1 and chBuffer2 here> ] ; then
....
else
....
fi
done
exec 3<&-
exec 4<&-
|