C Shell Commands

Special Characters for Issuing Commands


Character(s)Meaning
; separate commands
( ) group commands
| pipe stdout to stdin
|& pipe stderr and stdout to stdin
&& execute next command only if previous one is successful
|| execute next command only if previous one fails
& execute in background

Built-In C Shell Commands


alias display the list of currently defined aliases and their meanings
alias name display the definition of alias name
alias name wordlist define alias name to be wordlist. Use history commands to pass arguments (e.g., !* is all the arguments and !^ is the first argument)
dirs display the directory stack (BSD)
eval arg read the argument list and executes the arguments in the current shell. This allows the generation of commands using variable or filename expansion; normally parsing occurs before this expansion
exec cmd execute cmd without forking a new shell (UNIX overlays current shell with cmd).
foreach name (wordlist) ... end set variable name to each value in wordlist and executes the ... commands between the foreach and matching end statement using this value of name
glob wordlist display wordlist using history, variable and filename expansion.
Puts a null character between words and does not include a carriage return at the end
hashstat display statistics indicating how successful the hash table has been at locating commands (BSD)
history display the history list
history n display the last n lines of the history list (BSD)
history -r n like history n, but in reverse order (BSD)
history -h n like history n, but leaving off the event numbers (BSD)
if (expr) ... conditional statement: execute following command only if expr evaluates true
limit list all currently imposed resource limits (BSD)
limit rsc list the current limit for resource rsc
limit rsc max_use set a limit of max_use for rsc for each individual process (and any subprocesses)
login terminate the login shell and invokes the program /bin/login (BSD)
logout terminate the login shell. This command must be used if ignoreeof is set
nohup ignore the hangup signal in the current shell
nohup cmd ignore the hangup signal for cmd
popd pop the top directory off the directory stack and changes directories to the new top (BSD)
popd + n pop the nth directory off the directory stack (BSD)
pushd exchange the top two directories and changes directories to the new top (BSD)
pushd dir put directory dir on the directory stack and changes to it (BSD)
pushd + n put the nth directory on the top and changes to it (BSD)
rehash rebuild the internal hash table (like source ~/.cshrc it updates the list of known executables in $path)
repeat count cmd repeat cmd count times
set display the list of currently defined C shell variables and their values
set name[n] = word set (the nth word of) name to the single word word
set name = (wordlist) set the variable name to wordlist
setenv name set the environment variable name to the null string
setenv name value set environment variable name to value
sleep n suspend execution for an interval of n seconds
source name execute C shell script name in the current shell
Bourne shell equivalent: . name
source -h name read commands from script name and places them in the current history list without executing them (BSD)
time display a summary of the time used by the current shell and its children.
time cmd display a summary of the time used by executing cmd
umask display the current value for umask.
umask value set the value of umask to value, UNIX uses the umask value to set the permissions for newly created files and directories to the inverse value of umask
umask 022 will result in 755 for executables or directories and in 644 for plain files
unalias pattern remove all alias definitions matched by pattern
unhash disable use of the internal hash table
unlimit remove all resource limitations (BSD)
unlimit rsc remove limitations for rsc
unset[env] pattern release all (environment) variables matched by pattern
wait wait for all background jobs to complete. This command can be interrupted
while (expr) ... end as long as expr evaluates to nonzero, the C shell executes the commands between the while and matching end statements
@ display the values of all C shell variables
@ name[n] = expr set the (nth word of) variable name to value of expr; expr can contain numeric operators.
Do not forget the blank behind @!