Say I have the following:
set OrigList [exec -keepnewline -- ls -la | grep abc]
then say I want to break-out the first (i.e. - permissions), third (i.e. - owner) and ninth (i.e. - filename) fields each to a seperate list variable ...
foreach elem $OrigList {
lappend perm [lindex $elem 0]
lappend owner [lindex $elem 2]
lappend fname [lindex $elem 8]
}
puts $perm
puts $owner
puts $fname
My output from my puts cmds contains only the elements from the first row (of the ls -la). I know it's because the OrigList variable is being treated as a string, not as a list.
How do I get the OrigList variable to act like a list?
set OrigList [exec -keepnewline -- ls -la | grep abc]
then say I want to break-out the first (i.e. - permissions), third (i.e. - owner) and ninth (i.e. - filename) fields each to a seperate list variable ...
foreach elem $OrigList {
lappend perm [lindex $elem 0]
lappend owner [lindex $elem 2]
lappend fname [lindex $elem 8]
}
puts $perm
puts $owner
puts $fname
My output from my puts cmds contains only the elements from the first row (of the ls -la). I know it's because the OrigList variable is being treated as a string, not as a list.
How do I get the OrigList variable to act like a list?