如何打印执行TCL脚本的行号?
#! /usr/bin/tclsh
set a "100"
set b "200"
set c [expr $a + $b]
puts [info script] ;# it will display the script name which it is executing.
# similarly I need to print the script line number.
puts $c
Run Code Online (Sandbox Code Playgroud) 如何在命令行参数中使用尖括号?
假设输入是: filename -w <input.txt>
这input.txt
是第二个命令行参数,它是程序的输入文件,这里 input.txt 必须用尖括号( <input.txt>
)括起来。但是如果我使用尖括号,我就会出错。错误是:
sh: -c: line 0: syntax error near unexpected token `newline'
sh: -c: line 0: `demo -w '
Run Code Online (Sandbox Code Playgroud) tcl ×2