jeudi 4 juin 2015

Pick out certain lines from files

I am writing a tcl script that reads from a file and displays certain lines from this file. I can read from the file n problem but I cant figure out how to pick out certain lines BEFORE filtering out what I don't need. I am reading the file to a list and then using the following code to filter it out;

proc listFromFile {/.../.../.../file_test.file} {
set f [open /.../.../.../file_test.file r]
set data [split [string trim [read $f]]]
close $f
return $data
}
set f [listFromFile /.../.../.../file_test.file]
set f [lsort -unique $f]
set f [lsearch -all -inline $f "test_*"

The lines within the file look like

$(eval $(call CreateUvmTest, other, test_runtest1 ...
$(eval $(call CreateUvmTest, KEYWORD, test_runtest2 ...
$(eval $(call CreateUvmTest, KEYWORD, test_runtest3 ...
$(eval $(call CreateUvmTest, other, test_runtest4 ...

How would I pick out the lines containing KEYWORD as a whole before I filter out everything else I don't need? The lines containing KEYWORD are randomly within the file along with other tests. Is this a possibility at all?

Aucun commentaire:

Enregistrer un commentaire