Reputation: 13
I have the following text file with me:
.............................................. .............................................. .............................................. .............................................. xyz (MTU) 301.2017
I tried the following :
set fd [open "textfile.file" r]
set data [read $fd]
set input_list [split $data "\n"]
set pattern [lsearch -all -inline $data "xyz (MTU)*"]
foreach elem $pattern{
puts "[lindex $elem 3]"
}
But it gives a blank output ?
Upvotes: 0
Views: 73
Reputation: 137627
The problem is that there's a space at the start of the line. If I add a space at the start of the pattern, it works:
% set pattern [lsearch -all -inline -glob $input_list " xyz (MTU)*"]
{ xyz (MTU) 301.2017}
Upvotes: 1