变量赋值
set x 10
#设定x的值为10
计算后变量赋值
set a 3
set x [expr $a*3]
#[]相当于bash中$()或``,作为一个单独的命令运行
转义后赋值
set a 3
set b \$a
#b=$a rather than b=3
变量赋值字符串
变量的引用
变量引用需要dollar符
# $variable
替换
打印单个字符
puts $variable or puts string
打印字符串
打印字符串需要用{},将字符串用{}或“”包起来
If the string has more than one word, you must enclose the string in double quotes or braces ({}). A set of words enclosed in quotes or braces is treated as a single unit, while words separated by whitespace are treated as multiple arguments to the command. Quotes and braces can both be used to group several words into a single unit. However, they actually behave differently. In the next lesson you‘ll start to learn some of the differences between their behaviors. Note that in Tcl, single quotes are not significant, as they are in other programming languages such as C, Perl and Python.
https://www.tcl.tk/man/tcl8.5/tutorial/Tcl1.html
双引号和大括号的区别
原文:https://www.cnblogs.com/movit/p/14775140.html