csh 命令详解

| 选择喜欢的代码风格  

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

csh 命令安装:


-bash/zsh: csh: 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/csh

# Docker
docker run cmd.cat/csh csh

csh 命令补充说明:


csh 是具有文件名补全和命令行编辑功能的 C shell,csh 是最早的 C 风格的 Unix shell 之一,由 Bill Joy 在 20 世纪 70 年代早期开发,最初用于 BSD Unix。

csh 命令语法:


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

csh 命令选项:


-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. (+)

After processing of flag arguments, if arguments remain but none of the -c, -i, -s, or -t options were given, the first argument is taken as the name of a file of commands, or ''script'', to be executed. The shell opens this file and saves its name for possible resubstitution by '$0'. Because many systems use either the standard version 6 or version 7 shells whose shell scripts are not compatible with this shell, the shell uses such a 'standard' shell to execute a script whose first character is not a '#', i.e., that does not start with a comment.

csh 命令实例:


csh 启动交互式 shell 会话:

csh

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

csh -f

csh 执行具体命令:

csh -c "echo 'csh is executed'"

csh 执行特定脚本:

csh path/to/script.csh

csh 扩展阅读:




csh 命令评论