私は2つのファイルを持っています。
- ファイル
0 10 20 30
10 20 30 40
0 10 23 34
ファイル a の値は (x1 y1 x2 y2 形式)
- ファイル b
- 形式は PMM xy -(数値)
PMM 10 20 -100
PMM 20 30 -150
PMM 50 60 -100
ファイルBで、フィールド4,5(フィールド1としてPから始まる)がファイルaの範囲内にあるかどうかを検索したい. そうであれば、FileB の行を印刷しないでください。そうでない場合は、その行を印刷します。
ファイル b の行を出力しません。
x1 < x < x2 & y1 < y < y2
そのため、スクリプトの O/P は
ファイル c
PMM 50 60 -100
私は tcl で次のスクリプトを作成しましたが、私の問題は、ファイル a 内のファイル b のすべてのコンテンツを検索していないことです。
set abc "b"
set ab "a"
set cord [open $ab "r"]
if [catch {open $abc r} FILE_R {
puts "failed to read $abc"
return -1
}
while { [gets $FILE_R line] >= 0 } {
if [regexp {^#} $line ] {
} else {
set x_cord [lindex $line 3]
set y_cord [lindex $line 4]
while { [gets $cord line] >= 0 } {
set x1_cord [lindex $line 0]
set y1_cord [lindex $line 1]
set x2_cord [lindex $line 2]
set y2_cord [lindex $line 3]
if { [expr x1_cord < x_cord && x_cord < x2_cord && y1_cord < y_cord && y_cord < y2_cord ] == 1 } {
} else {
puts $line
}
}
}
}
close $FILE_R