Skip to content
Surf Wiki
Save to docs
technology/programming-languages

From Surf Wiki (app.surf) — the open knowledge base

Tcsh

Unix shell based on and compatible with the C shell


Summary

Unix shell based on and compatible with the C shell

FieldValue
nameTENEX C Shell
screenshotTC Shell.png
screenshot size250px
captionScreenshot of a sample tcsh session
developerKen Greer, Paul Placeway, Christos Zoulas, et al.
latest release version
latest release date
programming languageC
operating_systemCross-platform
genreUnix shell
license2002: BSD-3-Clause
1991: BSD-4-Clause
replacesC shell

1991: BSD-4-Clause tcsh ( “tee-see-shell”, “tee-shell”, or as “tee see ess aitch”, tcsh) is a Unix shell based on and backward compatible with the C shell (csh).

Shell

It is essentially the C shell with programmable command-line completion, command-line editing, and a few other features. Unlike the other common shells, functions cannot be defined in a tcsh script and the user must use aliases instead (as in csh). It is the native root shell for some BSD-based systems, including FreeBSD 13 and earlier. (FreeBSD 14 changed the default root shell to sh to match the default user shell whereas OpenBSD uses the Korn shell ksh for both root and regular users.)

tcsh added filename and command completion and command line editing concepts borrowed from the TENEX operating system, which is the source of the “t”. | access-date = 29 December 2010

tcsh is very stable but new releases continue to appear roughly once a year, consisting mostly of minor bug fixes.

On many systems, such as macOS and Red Hat Linux, csh is actually tcsh. 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 (although behavior may be altered depending on which name is used).

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.

History

The “t” in tcsh comes from the “T” in TENEX, an operating system which inspired Ken Greer at Carnegie Mellon University, the author of tcsh, with its command-completion feature.{{cite web |archive-url =https://web.archive.org/web/20120414085306/http://www.tcsh.org/tcsh.html/THE_T_IN_TCSH.html |archive-date =14 April 2012 |url-status =dead |access-date =31 October 2013

Significant features

  • Command history
    • The built-in history command displays the previously entered commands
    • Use of / at the command line to allow the user to select a command from the history to edit/execute
    • Invoking previous commands using command history
      • !! executes the previous command
      • !n executes the nth command that was previously executed
      • !-n executes the command that was executed n commands ago
      • !*string* executes the most recently executed command that starts with string
      • !?*string* executes the most recently executed command that contains string
    • Using history in new commands
      • !* - refers to all of the arguments from the previous command
      • !$ - refers to the last argument from the previous command
      • !^ - refers to the first argument from the previous command
      • !:n - refers to the nth argument from the previous command
      • !:m-n - refers to the mth through nth arguments from the previous command
      • !:n-$ - refers to the nth through the last argument from the previous command
  • Command line editing
  • Auto-completion of file names and variables as well as programmable completion at the command line
  • Alias argument selectors; the ability to define an alias to take arguments supplied to it and apply them to the commands that it refers to. Tcsh is the only shell that provides this feature (in lieu of functions).
    • \!# - argument selector for all arguments, including the alias/command itself; arguments need not be supplied.
    • \!* - argument selector for all arguments, excluding the alias/command; arguments need not be supplied.
    • \!$ - argument selector for the last argument; argument need not be supplied, but if none is supplied, the alias name is considered to be the last argument.
    • \!^ - argument selector for first argument; argument MUST be supplied.
    • \!:n - argument selector for the nth argument; argument MUST be supplied; n=0 refers to the alias/command name.
    • \!:m-n - argument selector for the arguments from the mth to the nth; arguments MUST be supplied.
    • \!:n-$ - argument selector for the arguments from the nth to the last; at least argument n MUST be supplied.
    • \!:n* - argument selector for the arguments from the nth to the last; sufficient arguments need not be supplied.
  1. Alias the cd command so that when you change directories, the contents are immediately displayed. alias cd 'cd !* && ls'
  • Wildcard matching if ( "$input" =~ [0-9]* ) then echo "the input starts with an integer" else echo "the input does NOT start with an integer" endif
  • Job control
  • The built-in where command. Works like the which command but shows all locations of the target command in the directories specified in $PATH rather than only the one that will be used.

Deployment

Early versions of Mac OS X shipped with tcsh as the default shell, but the default for new accounts became bash as of 10.3, then zsh as of 10.15. (tcsh is still provided, and upgrading the OS does not change the shell of any existing accounts). tcsh was the default root shell of FreeBSD prior to 14.0 (when it switched to an Almquist shell derivative which was already the default user shell) and its descendants like DragonFly BSD and DesktopBSD.

References

References

  1. (2002-03-08). "remove clause 3 of the copyright.".
  2. (2014-07-14). "Remove clause 3 of the copyright (changed in other files 2002-03-08).".
  3. (1991-07-04). "Tcsh-6.00 release".
  4. "FreeBSD Quickstart Guide for Linux Users".
  5. "OpenBSD for Linux Users".
  6. [https://web.archive.org/web/20060117151444/http://www.tcsh.org/tcsh.html/DESCRIPTION.html tcsh(1) man page]. tcsh.
  7. Fixes file in tcsh-17 June 2000.
  8. [https://launchpad.net/ubuntu/+source/csh Ubuntu - Details of package csh]. launchpad.net.
  9. [https://tracker.debian.org/pkg/csh Debian - Details of package csh]. tracker.debian.org.
  10. [https://launchpad.net/ubuntu/+source/tcsh Ubuntu - Details of package tcsh]. launchpad.net.
  11. [https://tracker.debian.org/pkg/tcsh Debian - Details of package tcsh]. tracker.debian.org.
  12. "FreeeBSD 14.0 Release Notes".
Wikipedia Source

This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.

Want to explore this topic further?

Ask Mako anything about Tcsh — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report