LinuxCommandLibrary

tcsh

Run an interactive shell

TLDR

Start an interactive shell session

$ tcsh
copy

Start an interactive shell session without loading startup configs
$ tcsh -f
copy

Execute specific [c]ommands
$ tcsh -c "[echo 'tcsh is executed']"
copy

Execute a specific script
$ tcsh [path/to/script.tcsh]
copy

Check a specific script for syntax errors
$ tcsh -n [path/to/script.tcsh]
copy

Execute specific commands from stdin
$ [echo "echo 'tcsh is executed'"] | tcsh
copy

SYNOPSIS

tcsh [ -bcDefFimnqstvVxX ] [ argument ... ]

PARAMETERS

-b
    Force a break from option processing. Remaining arguments are not interpreted as options.

-c string
    Execute commands from string.

-Dname[=value]
    Define the environment variable name to value, before tcsh executes any commands.

-d
    The shell reads and executes commands from the standard input; the end-of-file sends it to exit, instead of the shell exiting.

-E
    Exit immediately if a command exits with a non-zero status.

-f
    Fast start. Do not read `.tcshrc' or `.login' (or `.cshrc' if `.tcshrc' is not found).

-F
    Use the file name completion.

-i
    Interactive shell. Standard input and standard error are attached to a terminal; ignores interrupts; LOGIN is set.

-l
    Login shell. Read `/etc/login' then `.login' (or `.cshrc' if `.login' is not found).

-m
    Set the 'monitor' option, so that job control is enabled.

-n
    Parse commands but do not execute them. Useful for checking syntax errors in shell scripts.

-q
    Accept QUIT signals and produce a core dump.

-s
    Read commands from standard input.

-t
    Read and execute one line of input.

-v
    Verbose: Print commands before executing them.

-V
    Very verbose: Like -v, but also expands history substitutions.

-x
    Echo commands before executing them.

-X
    Like -x, but expands history substitutions.

DESCRIPTION

tcsh is an enhanced, improved version of the original Berkeley UNIX C shell, csh. It's a command interpreter (shell) that can be used as an interactive login shell and also as a shell script command processor. tcsh is largely backward compatible with csh, but it adds many features, including command-line editing, history mechanism, spelling correction, job control, programmable completion, and a C-like expression syntax. It's designed to be more user-friendly and feature-rich than its predecessor. While still used, particularly in older systems and embedded environments, tcsh has been largely superseded by other shells like bash and zsh for interactive use and scripting, which offer more powerful scripting capabilities and better POSIX compliance.

CAVEATS

tcsh is not fully POSIX compliant, which can lead to portability issues when writing scripts intended for broader use. Its syntax, particularly for scripting, is considered less elegant and powerful compared to shells like bash and zsh.

STARTUP FILES

When tcsh starts, it executes commands from various startup files.
A login shell (invoked with -l) reads `/etc/login' followed by `.login' (or `.cshrc' if `.login' doesn't exist).
An interactive, non-login shell reads `.tcshrc' (or `.cshrc' if `.tcshrc' is not found).
Non-interactive shells only process files specified with the -c option.

JOB CONTROL

tcsh provides robust job control. You can suspend a running process with Ctrl+Z, and then resume it in the background using `bg` or in the foreground using `fg`. The `jobs` command lists the currently running or suspended jobs.

HISTORY

tcsh was developed by Ken Greer at Carnegie Mellon University in the late 1970s as an improved version of csh, the original Berkeley C shell created by Bill Joy. tcsh added many interactive features that made command-line interaction more convenient. It gained popularity as a user-friendly interactive shell, particularly in academic environments. While widely used for many years, its scripting capabilities have been eclipsed by other shells, resulting in a decline in its usage for scripting in modern Linux systems. It is still found as the default shell on some older systems or as a readily available alternative.

Its core purpose was to make command-line interaction more friendly, and it succeeded admirably during its peak usage.

SEE ALSO

csh(1), bash(1), zsh(1)

Copied to clipboard