Linux command
tcl 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Start an interactive Tcl shell
tclsh
Run a Tcl script
tclsh [script.tcl]
Run a script with arguments
tclsh [script.tcl] [arg1] [arg2]
Run in interactive mode
tclsh -i [script.tcl]
Specify encoding
tclsh -encoding utf-8 [script.tcl]
Execute a Tcl command
echo 'puts "Hello World"' | tclsh
说明
tclsh is the standard shell for the Tcl (Tool Command Language) scripting language. It reads and evaluates Tcl commands from standard input or from a script file. When invoked without arguments, it runs interactively with a % prompt. Several variables are set for scripts: argc contains the argument count, argv is a list of arguments, argv0 is the script name, and tcl_interactive indicates whether the shell is interactive. In interactive mode, the shell reads the ~/.tclshrc startup file before accepting commands. The prompts can be customized via tcl_prompt1 and tcl_prompt2 variables.
参数
- -encoding _name_
- Specify the character encoding for reading the script file (e.g., utf-8).
- -i
- Force interactive mode even when a script file is provided.
- -f
- Force the first non-option argument to be treated as a script file.
- -norc
- Do not load the user's startup file (~/.tclshrc).
- -t
- Equivalent to -i, forces interactive mode.
- --
- End of options; all following arguments are the script file and its arguments.
FAQ
What is the tcl command used for?
tclsh is the standard shell for the Tcl (Tool Command Language) scripting language. It reads and evaluates Tcl commands from standard input or from a script file. When invoked without arguments, it runs interactively with a % prompt. Several variables are set for scripts: argc contains the argument count, argv is a list of arguments, argv0 is the script name, and tcl_interactive indicates whether the shell is interactive. In interactive mode, the shell reads the ~/.tclshrc startup file before accepting commands. The prompts can be customized via tcl_prompt1 and tcl_prompt2 variables.
How do I run a basic tcl example?
Run `tclsh` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -encoding _name_ do in tcl?
Specify the character encoding for reading the script file (e.g., utf-8).