EXPRESSIONS
Expressions can be given to the C Shell commands like @, exit, if, set, and while. The non-file operators are similar to those in the C programming language and have the same precedence. Null or missing values are considered zero.
File Operators
d file
| true if file is a directory
|
e file
| true if file exists
|
f file
| true if file is a regular file
|
o file
| true if file owned by user
|
r file
| true if file is readable
|
w file
| true if file is writable
|
x file
| true if file is executable
|
z file
| true if file is zero length
|
Other Operators
(...)
| grouping (used to override precedence)
|
~ | ones complement
|
!
| logical negation
|
*, /, %
| multiplication, division, modulo
|
+,
| addition, subtraction
|
<<, >>
| bitwise shift left, bitwise shift right
|
<, >, <=, >=
| less than, greater than, less than or equal to, greater than or equal to
|
==, !=, =~, !~
| equal to, not equal to, equal to pattern, not equal to pattern (used with strings)
|
&
| bitwise AND
|
^
| bitwise exclusive OR
|
|
| bitwise OR
|
&&
| logical AND
|
| |
| logical OR
|
=
| assignment
|
++,
| increment, decrement
|
+=, =
| add assign, subtract assign
|
*=, /=, %=
| multiply assign, divide assign, modulo assign
|
CONTROL COMMANDS
foreach var (word1 word2 . . . wordn)
commands
end
Execute commands once for each word setting var to word. The break and continue commands can be used to terminate or continue the loop early.
goto label
Continue execution after the line with label: (cannot be in a while or for loop).
if (expr) command
Execute a single command if expr returns true
if (expr1) then
commands1
else if (expr2) then
commands2
. . .
else
commands3
endif
Execute commands1 if expr1 returns true, otherwise execute commands2 if expr2 returns true. Execute commands3 if expr1 and expr2 do not return true.
switch (string)
case label: commands
breaksw
case label: commands
breaksw
. . .
default: commands
breaksw
Execute commands for the case statement whose label matches string. If no case statement matches string, then the commands associated with default are executed. The breaksw commands causes execution to resume after endsw.
while (expr)
commands
end
Execute commands while expr is true. The break and continue commands can be used to terminate or continue the loop early.
OTHER COMMANDS
:
| null command; returns zero exit status
|
break
| exit from current enclosing foreach, or while loop
|
cd dir
| change directory to dir. If dir not specified, change directory to $HOME. If dir is a relative pathname not found in the current directory, cdpath is checked.
|
chdir [dir]
| same as cd
|
continue
| continue at start of next foreach or while loop
|
dirs
| display the current directory list
|
dirs l
| display the current directory list in long format
|
echo arguments
| display arguments terminated with a newline
|
echo n arguments
| display arguments without a terminating newline
|
eval command
| evaluate command and execute the result
|
exec command
| replace current process with command
|
exit
| exit from current program with value of status
|
exit (expr)
| exit from current program with value of expr
|
glob arguments
| perform filename expansion on arguments
|
hashstat
| display statistics for hashing attempts
|
history
| display the command history list
|
history [hr] n
| display n previous commands from history list:
|
| h
| display without command numbers
|
| r
| display in reverse order
|
limit [h] [resource [ limit ]]
| set or display a resource limitation. If h given (only by the super-user), then hard limits are used instead of the current limits. If no limit is given, then the current limit for resource is displayed. If no resource is given, all current limits are displayed.
|
| resource can be one of:
|
| cputime
| maximum cpu seconds per process
|
| filesize
| largest single file allowed
|
| datasize
| maximum data size for the process
|
| stacksize
| maximum stack size for the process
|
| coredumpsize
| maximum size of core dump
|
| limit is a number with an optional scale factor:
|
| nh
| n hours (cputime)
|
| nk
| n kilobytes (all except cputime)
|
| nm
| n megabytes (all except cputime), or n minutes (cputime)
|
| mm:ss
| minutes and seconds (cputime)
|
login
| terminate a login shell, invoke login, and prompt for a user name
|
login user
| terminate a login shell and login as user
|
login p
| same as login, except preserve current environment
|
logout
| terminate a login shell
|
nice [priority] [command]
| increment/decrement process priority for the current shell or command. The priority can be (default 4):
|
| +n
| increment the process priority value by n
|
| n
| decrement the process priority value by n (super-user only)
|
nohup
| ignore hangups (HUP) in C shell scripts
|
nohup command
| execute command with hangups (HUP) ignored
|
onintr
| terminate C shell scripts on interrupt
|
onintr
| ignore all interrupts
|
onintr label
| execute goto label on interrupt
|
popd
| discard top entry from directory stack
|
popd +n
| discard nth entry from directory stack
|
pushd
| switch top two directory stack elements
|
pushd +n
| switch nth directory stack entry and cd to it
|
pushd dir
| move current directory to top of directory stack and cd to dir
|
rehash
| recompute hash table
|
repeat n command
| execute command n times
|
set
| display a list of variable names and their values
|
shift [var]
| shift components of var once to the left, discarding the first component. If no var specified, use argv.
|
source [h] file
| read and execute commands from file. If h specified, read commands, but do not execute.
|
time
| display a summary of time used by the current shell
|
time command
| display a summary of time used by command
|
umask
| display current value of the file creation mask
|
umask mask
| set default file creation mask to octal mask
|
unhash
| disable use of internal hash table
|
unlimit [ resource]
| remove limitations from all or the specified resource
|
unlimit h [ resource]
| remove hard limits from all or the specified resource (super-user only)
|
|