Comparison of Features of three UNIX shells
|
FEATURE |
C SHELL |
BOURNE SHELL |
KORN SHELL |
|
Variables Assign values to
variables |
set x = 5 |
x=5 |
x=5 |
|
Accessing values of
variables |
echo $x |
echo $x |
echo $x or print $x |
|
Command
Substitution Assigning output of command |
set d = `date` |
d=`date` |
d=$(date) |
|
Accessing values |
echo $d |
echo $d |
print $d |
|
Arithmetic operations |
@ var = 5 +1 |
var=`expr 5 + 1` |
((var = 5 +1)) |
|
Aliases |
alias m more |
Not available |
alias m=more |
|
Programming Constructs: If C then |
if (expr) then commands endif |
if [ expr ] then commands fi |
if (( expr )) then commands fi |
|
If C then else |
if ( expr) then commands else if commands else commands endif |
if [ expr ] then commands elif commands else commands fi |
if (( expr )) then commands elif commands else commands fi |
|
Switch and case |
switch (value) case pattern1: commands breaksw case pattern2: commands breaksw default: command breaksw endsw |
case value in pattern1) commands
;; pattern2) commands;; *) commands ;; esac |
case value in pattern1) commands;; pattern2) commands;; *) commands ;; esac |
|
goto |
goto label |
Not Available |
Not Available |
|
if |
if |
Not Available |
Not Available |
|
Loops While |
while (expr) commands end |
while command do command done |
while command do command done |
|
For/foreach |
foreach var (list) commands end |
for var in list do commands done |
for var in list do commands done |
|
until |
Not available |
until command do command done |
until command do command done |
|
Initialization
Files Executed at login |
.login |
.profile |
.profile |
|
Executed every time shell
is invoked |
.cshrc |
Not available |
.kshrc |
|
Relational
Operators Equal to Not equal to Less than or equal Less than Greater than or equal to Greater than And operator Or operator |
== != <= < >= > && || |
= -ne -le -lt -ge -gt -a -o |
= != <= < >= > && || |