tcsh 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

tcsh 命令安装:


-bash/zsh: tcsh: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install tcsh

# Debian
apt-get install tcsh

# Ubuntu
apt-get install tcsh

# Alpine
apk add tcsh

# Arch Linux
pacman -S tcsh

# Kali Linux
apt-get install tcsh

# CentOS
yum install tcsh

# Fedora
dnf install tcsh

# OS X
brew install tcsh

# Raspbian
apt-get install tcsh

# Dockerfile
dockerfile.run/tcsh

# Docker
docker run cmd.cat/tcsh tcsh

tcsh 命令补充说明:


tsch 也称为 - TENEX C Shell,和 csh - C Shell 是两种不同的 Unix / Linux 命令 Shell,tsch 是 csh 的一种改进和扩展,由 Paul Placeway 和 Chris Zimmerman 开发,旨在修复一些 csh 的问题和限制。它最早出现在 TENEX 操作系统上,因此得名 TENEX C Shell。

tcsh 不同于其他的 shell(如 bash),因为控制结构更符合程序设计语言的格式。如 tcsh 的 test 条件的控制结构是表达式,而不是 Linux 命令,得到的值是逻辑值 true 或 false,tcsh 的表达式与 C 语言中的表达式基本相同。

tcsh 命令语法:


tcsh [-bcdefFimnqstvVxX] [-Dname[=value]] [arg ...]
tcsh -l

tcsh 命令选项:


If the first argument (argument 0) to the shell is ‘-’ then it is a login
shell.  A login shell can be also specified by invoking the shell with the 
-l flag as the only argument.

The rest of the flag arguments are interpreted as follows:

-b      Forces a “break” from option processing, causing any further shell
       arguments to be treated as non-option arguments.  The remaining
       arguments will not be interpreted as shell options.  This may be
       used to pass options to a shell script without confusion or
       possible subterfuge.  The shell will not run a set-user ID script
       without this option.

-c      Commands are read from the following argument (which must be
       present, and must be a single argument), stored in the command
       shell variable for reference, and executed.  Any remaining
       arguments are placed in the argv shell variable.

-d      The shell loads the directory stack from ~/.cshdirs as described
       under Startup and shutdown, whether or not it is a login shell. (+)

-Dname[=value]
       Sets the environment variable name to value.  (Domain/OS only) (+)

-e      The shell exits if any invoked command terminates abnormally or
       yields a non-zero exit status.

-f      The shell does not load any resource or startup files, or perform
       any command hashing, and thus starts faster.

-F      The shell uses fork(2) instead of vfork(2) to spawn processes. (+)

-i      The shell is interactive and prompts for its top-level input, even
       if it appears to not be a terminal.  Shells are interactive without
       this option if their inputs and outputs are terminals.

-l      The shell is a login shell.  Applicable only if -l is the only flag
       specified.

-m      The shell loads ~/.tcshrc even if it does not belong to the
       effective user.  Newer versions of su(1) can pass -m to the shell.
       (+)

-n      The shell parses commands but does not execute them.  This aids in
       debugging shell scripts.

-q      The shell accepts SIGQUIT (see Signal handling) and behaves when it
       is used under a debugger.  Job control is disabled. (u)

-s      Command input is taken from the standard input.

-t      The shell reads and executes a single line of input.  A ‘\’ may be
       used to escape the newline at the end of this line and continue
       onto another line.

-v      Sets the verbose shell variable, so that command input is echoed
       after history substitution.

-x      Sets the echo shell variable, so that commands are echoed
       immediately before execution.

-V      Sets the verbose shell variable even before executing ~/.tcshrc.

-X      Is to -x as -V is to -v.

--help  Print a help message on the standard output and exit. (+)

--version
       Print the version/platform/compilation options on the standard
       output and exit.  This information is also contained in the version
       shell variable. (+)

tcsh 命令实例:


tcsh 启动交互式 shell 会话:

tcsh

启动 tcsh 交互式 shell 会话而不加载启动配置:

tcsh -f

tcsh 执行具体命令:

tcsh -c "echo 'tcsh is executed'"

tcsh 执行特定脚本:

tcsh path/to/script.tcsh

tcsh 检查特定脚本是否存在语法错误:

tcsh -n path/to/script.tcsh

tcsh 从 stdin 执行特定命令:

echo "echo 'tcsh is executed'" | tcsh

tcsh 扩展阅读:




tcsh 命令评论