C Shell
csh was the shell that William Joy wrote for BSD. csh accepted the same Unix commands as other shells, but had a very different syntax (for variable assignments, control flow, and such). csh is not compatible with the Bourne Shell.
C Shell
This programming language may be used to instruct a computer to perform a task.
Listed below are all of the tasks on Rosetta Code which have been solved using C Shell.
This programming language may be used to instruct a computer to perform a task.
Execution method: | Interpreted |
---|---|
See Also: |
|
C Shell is an implementation of UNIX Shell.
Other implementations of UNIX Shell.
BSD keeps the C shell at /bin/csh
, but few persons use it.
Hashbang lines for C shell scripts should use the -f option:
<lang csh>#!/bin/csh -f</lang>
Syntax
C | C Shell | Bourne Shell |
---|---|---|
<lang c>#include <stdio.h>
int main() { int n; n = 13; printf("%d\n", n); while (n != 1) { if (n % 2) n = 3 * n + 1; else n /= 2; printf("%d\n", n); } return 0; }</lang> |
<lang csh>
if ($n % 2) then @ n = 3 * $n + 1 else @ n /= 2 endif echo $n end
|
<lang bash>
if expr $n % 2 >/dev/null; then n=`expr 3 \* $n + 1` else n=`expr $n / 2` fi echo $n done
|
<lang csh>% @ n = 10 - 3 - 2 % echo $n 9</lang>
<lang csh>% @ n = (10 - 3) - 2 % echo $n 9</lang>