Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

comparision of files and script

Status
Not open for further replies.

sun_ray

Advanced Member level 3
Advanced Member level 3
Joined
Oct 3, 2011
Messages
772
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Activity points
6,828
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.
 

Can anyone write the script in tcl and provide it?
 

Hai sunray,

This is simple in tcl just open the two file using tcl

store all the lines in a list or array

so now u got two list..

Then compare the two list... now u will get all the missing things..
 

hai sunray,

As per ur private request i spend time and do the code for u... enjoy......

Code:
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
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top