Computer History - Herong's Notes - Version 3.11, by Dr. Herong Yang
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