sun_ray
Advanced Member level 3
Can anyone please provide a script to compare between two file lists which should have the same list of files in each of them. The script will be able to say if there are any files missing.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
proc intersection_lists { fileopen1 fileopen2 } {
set file1 [open $fileopen1 r]
set file2 [open $fileopen2 r]
while {[gets $file1 line] >= 0} {
lappend filelist1 $line
}
while {[gets $file2 line] >= 0} {
lappend filelist2 $line
}
for {set i 0} {$i< [llength $filelist1]} {incr i} {
for {set j 0} {$j< [llength $filelist2]} {incr j} {
lappend en [string compare [lindex $filelist1 $i] [lindex $filelist2 $j]]
}
set envar [lsearch $en "0"]
if {$envar eq -1} {
puts "[lindex $filelist1 $i]"
}
set en {}
}
}
intersection_lists file_1.txt file_2.txt
intersection_lists file_2.txt file_1.txt