Reputation: 3597
I want to use the following command in a tcl script :
sed -n '452,$ { /wire/ {p;q} }' /tmp/foo
For that I have changed this command as follow :
set MIDLINE2 [ exec sed -n {1134,$ {/wire/{=;q}}} foo.txt ]
It gives me correct answer but in place 1134 I want to use variable $MIDLINE that has value 1134. How can I do that ? Please suggest some way.
Upvotes: 0
Views: 1802
Reputation: 386030
This is a simple problem of quoting. You're using curly braces which inhibits variable substitution. Since you want variable substitution you need to use something else.
set MIDLINE2 [ exec sed -n "$MIDLINE,\$ {/wire/{=;q}}" foo.txt ]
Notice that you have to put a backslash in front of the literal $
, otherwise Tcl will try to substitute that, too.
Upvotes: 4