Tcsh Shell Script File Examples

This section provides some Tcsh script file examples.

The Tcsh shell supports executable script files, which are collections of Bash command lines stored in text files. When a script file is executed, all command lines in the script file will be executed in the same order they appear in the file.

Here is a Tcsh shell script file, f, which uses 3 command programs to print information about the specified file:

#!/bin/bash
# f name
if ( $#argv == 0 ) then
   echo "Usage: f name"
   exit
endif
if ( ! -e $1 ]) then
   echo "Error: File $1 does not exist"
   exit
endif
echo ""
echo "File list info:"
ls -l $1 # list file info
echo ""
echo "Numer of lines:"
wc -1 $1 # count words in this file
echo ""
echo "File type:"
file $1

Tcsh shell supports startup run commands stored in the .tcshrc in the home directory. Here is a simple example of .tcshrc file:

set prompt="%S %m %/ %s%% "
set path = ( . /usr/local/bin /usr/bin /bin)
set history=50
set savehist
setenv MANPATH /usr/local/man:/usr/man
umask 022
limit coredumpsize 0
setenv EDITOR vi
setenv VISUAL vi
setenv PAGER more

Table of Contents

 About This Book

 1957 - FORTRAN Language Developed by IBM

 1970 - UNIX Operating System Developed by AT&T Bell Labs

 1971 - FTP Protocol Created by Abhay Bhushan

 1972 - C Language Developed by Dennis Ritchie

 1976 - vi Text Editor Developed by Bill Joy

 1977 - Apple II Designed by Steve Jobs and Steve Wozniak

 1977 - The Bourne Shell Developed by Stephen Bourne

 1978 - The C Shell Developed by Bill Joy

 1978 - Bash (Bourne-Again Shell) Developed by Brian Fox

1979 - The Tcsh (TENEX C Shell) Developed by Ken Greer

 What Is Tcsh?

 Tcsh Command Line Examples

Tcsh Shell Script File Examples

 1983 - "Sendmail" Mail Transfer Agent Developed by Eric Allman

 1984 - Macintosh Developed by Apple Inc.

 1984 - X Window System Developed a MIT Team

 1991 - WWW (World Wide Web) Developed by Tim Berners-Lee

 1991 - Gopher Protocol Created by a University of Minnesota Team

 1995 - Java Language Developed by Sun Microsystems

 1995 - PHP: Hypertext Preprocessor Created by Rasmus Lerdorf

 2002 - .NET Framework Developed by Microsoft

 References

 PDF Printing Version