C shell
The C shell (csh or the improved version, tcsh) is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp. The C shell is a command processor which is typically run in a text window, allowing the user to type and execute commands. The C shell can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. What differentiated the C shell from others, especially in the 1980s, were its interactive features and overall style. Its new features made it easier and faster to use. The overall style of the language looked more like C and was seen as more readable. On many systems, such as macOS and Red Hat Linux, csh is replaced by tcsh, an improved version of csh. Often one of the two files is either a hard link or a symbolic link to the other, so that either name refers to the same improved version of the C shell. The original csh source code, under src/bin/csh/ , and binary are part of NetBSD, and OpenBSD.…
The C shell (csh or the improved version, tcsh) is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp. The C shell is a command processor which is typically run in a text window, allowing the user to type and execute commands. The C shell can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. What differentiated the C shell from others, especially in the 1980s, were its interactive features and overall style. Its new features made it easier and faster to use. The overall style of the language looked more like C and was seen as more readable. On many systems, such as macOS and Red Hat Linux, csh is replaced by tcsh, an improved version of csh. Often one of the two files is either a hard link or a symbolic link to the other, so that either name refers to the same improved version of the C shell. The original csh source code, under src/bin/csh/ , and binary are part of NetBSD, and OpenBSD. On Debian and some derivatives (including Ubuntu), there are two different packages: csh and tcsh. The former is based on the original BSD version of csh and the latter is the improved tcsh. tcsh added filename and command completion and command line editing concepts borrowed from the Tenex system, which is the source of the "t". Because it only added functionality and did not change what already existed, tcsh remained backward compatible with the original C shell. Though it started as a side branch from the original source tree Joy had created, tcsh is now the main branch for ongoing development. tcsh is very stable but new releases continue to appear roughly once a year, consisting mostly of minor bug fixes. ====Aliases==== Aliases allow the user to type the name of an alias and have the C shell expand it internally into whatever set of words the user has defined. For many simple situations, aliases run faster and are more convenient than scripts. set filter = "$home"'/filter' mkfifo "$filter" cat "$filter" & ( ( ls /root/ || echo No access. ) > "$filter" ) >& /dev/null Systems supporting file descriptors as files may use the following workaround. ( ( ( echo ok ; ) > /dev/fd/0 ) >& /dev/null if ( expression ) command The long form uses then, else and endif keywords to allow for blocks of commands to be nested inside the condition. if ( expression1 ) then commands else if ( expression2 ) then commands ... else commands endif If the else and if keywords appear on the same line, csh chains, rather than nests them; the block is terminated with a single endif. switch ( string ) case pattern1: commands breaksw case pattern2: commands breaksw ... default: commands breaksw endsw while ( expression ) commands end foreach loop-variable ( list-of-values ) commands end repeat integer command Creates a variable large enough to hold 1024 elements. set fixed = {,}{,}{,}{,}{,}{,}{,}{,}{,}{,} exit ! ! 256 # Returns 1. !/bin/csh -f set cmdlist = ( 'date # 1'\ 'uname # 2'\ 'tty # 3'\ 'id # 4' ) echo -n 'Enter a number to execute a command from the history: ' set cmdexec = "$ 0 && \ "$cmdexec" & /dev/null if ( "$status" ) then echo 'Invalid event number.' foreach cmd ( $cmdlist:q ) echo "$cmd" end exit -1 endif eval "$cmdlist[$cmdexec]" Prefer breaking codes by recursing the script as workaround for functions. !/bin/csh -f if ( ! "$?main" ) then if ( ! "$?0" ) then echo 'You must run this script by explicitly calling its file.' exit -1 endif alias function 'set argv = ( \!* ) ; source "$main"' set main = "$0" set ret = "`function myfunc`" echo "$ret" exit endif goto "$1" ; shift myfunc: function myfunc2 echo "A function." exit myfunc2: echo "Another function." exit historical 2BSD csh source code dated 2 February 1980. The Unix Tree, complete historical Unix distributions. Csh programming considered harmful. Top Ten Reasons not to use the C shell.
References
No reference rows published for this article.
Cite this article
MLA
"C shell." encyclopegia.org, 2026, https://encyclopegia.org/wiki/c-shell. Accessed 24 November 2026.
Chicago
"C shell." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/c-shell.
APA
encyclopegia.org. (2026). C shell. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/c-shell
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON