reading two files, comparing, printing when unmatched value is seen
Hello,
I have two files:
file1
1
2
3
4
5
file2
"a","b",,,,,"c","1",.....
"s","d",,,,,"s","1",.....
"a","c",,,,,"d","1",....
"f","v",,,,,,"f","2",.....
etc
I have to read "1" from file1 and grab all records in file2 (say column 6 in file2 is "1") until the column changes its value ( here it changes to 2 ).
go back to file 1, get next value (2) and then grab all values in file 2 till it gets a different value (may not be 3, different than 2) etc..and continue.
I tried this with While ...do ..done...it takes lot of time due to the size of file 2.
(file2 will have 30 columns). I hope you understand my question.
this is a rough script on which i was working on. i do not want to use two while loops
while read number
do
while read column
do
var = `echo read column | cut -d -6f "," |
if $number == $var
then
do ......
done < file2
done < file1
Last edited by i.scientist; 06-12-2008 at 08:48 AM..
Reason: script addition