TCL雙引號 花括號 中括號

2021-07-23 20:14:23 字數 1638 閱讀 3551

tcl的執行分為兩步,第一步替換,第二步執行。。

在方括號中的內容將在替換步驟中計算出結果,整體替換為結果,類似於c中呼叫函式。方括號在反斜槓後或在花括號內無此作用。例子:

set b "\[set y ]"  ;#y值有更新

puts $b

輸出。。[set y ]

set z ]};#x值有更新

puts $z

輸出。。[set x ]

在雙引號和花括號中的內容將視為乙個引數

在雙引號中的內容在替換步驟中,執行替換。。例如,

puts "the current stock value is $varname"  中的varname將會被替換為varname的值。

大多在反斜槓後的內容表示不被替換。。如 \",但有一些反斜槓後的內容表示要被替換,如下表中內容。。但是如果乙個反斜槓在行尾,表示下一行的內容和這行的內容是同一行,tcl將會用乙個空格替換行尾的反斜槓。。

string

output

hex value

\aaudible bell

0x07

\bbackspace

0x08

\fform feed (clear screen)

0x0c

\nnew line

0x0a

\rcarriage return

0x0d

\ttab

0x09

\vvertical tab

0x0b

\0dd

octal value

d is a digit from 0-7

\uhhhh

h is a hex digit 0-9,a-f,a-f. this represents a 16-bit unicode character.

\xhh....

hex value

h is a hex digit 0-9,a-f,a-f.notethat the \x substitution "keeps going" as long as it has hex digits, and only uses the last two, meaning that \xaa and \xaaaa are equal, and that \xaaand anyway will "eat" the a of "and". using the \u notation is probably a better idea.

花括號中的內容將不被替換,除了行尾的反斜槓。。但,據參考鏈結表示。expr後跟花括號,執行速度更快。i.e. expr 比expr $i*10快

雙引號和花括號的這種用法只有當它們用來組織乙個引數時才有作用。。例子:

set z albany

set z_label "the capitol of new york is: "

puts "$z_label "

puts

第一行輸出。。the capitol of new york is: 。。(引號已經起了組織乙個引數的作用,故花括號不再起這種作用,作為普通字元)

第二行輸出。。who said, "what this country needs is a good $0.05 cigar!"?

shell 總結 單引號 雙引號 花括號

chenxb computercxb echo 123test path 123test path chenxb computercxb echo 123test path 123test usr lib lightdm lightdm usr local sbin usr local bin us...

shell中單引號 雙引號,小括號 大括號的使用

一 shell中單引號 和雙引號 1 當使用echo來列印出固定字串常量時,不帶引號 帶單引號和帶雙引號,其輸出結果相同,如下 2 當使用echo來列印出變數的資訊時,使用單引號將不會去解析變數的名稱,而是直接將單引號中的內容列印處理,不帶引號或是使用雙引號將會解析出變數後將其列印 二 shell中...

雙引號和點括號區別

預處理器 發現 include 指令後,就會尋找後跟的檔名並把這個檔案的內容包含到當前檔案中。被包含檔案中的文字將替換源 檔案中的 include指令,就像你把被包含檔案中的全部內容鍵入到原始檔中的這個位置一樣。include 指令有兩種使用形式 include stdio.h 檔名放在尖括號中 i...