I've 2 files(file1,file2),have the same number of lines,30 lines max.I want to write data which are in the file1 but which is not in the file2.I try use foreach 2 time but I've many difficulties to write these data.Can you help me in the realization of this script?Thx
foreach a [split [read [open $file1] \n] {
set f 0
foreach b [split [read [open $file2] \n] {
if {[string equal $a $b]} {
# Found it, so we set f to 1 and we break this 2nd loop
set f 1
break
}
}
# if f is still 0, then there's no match and we add $a to the list
if {!$f} { lappend c $a }
}
And don't forget to close the files after finishing from them.
tho i would just check there md5 against eachother.. if it doesn't match then i would go and compare.. and do all the rest .. ( if the files arn't big files.. ofcourse..)
Just a very silly thought on this ... how about using the command to shell out and run an OS sommand - is it exec? - and invoking the diff command? Why reinvent the wheel?