Differing Features
Table 4-2 is a sampling of features that differ between bash and tcsh, Mac OS X’s former default shell.
|
Meaning/action |
bash |
tcsh |
|
Default prompt |
$ |
% |
|
Force redirection |
>| |
>! |
|
Force append |
>>! | |
|
Variable assignment |
var
|
set var
|
|
Set environment variable |
export var
|
setenv var val |
|
Command substitution |
$(command), '' |
|
|
Number of arguments |
$# |
$#argv |
|
Execute commands in file |
. file |
source file |
|
End a loop statement |
done |
end |
|
End case or switch |
esac |
endsw |
|
Loop through variables |
for/do |
foreach |
|
Sample |
if [$i -eq 5] |
if ($i= =5) |
|
End |
fi |
endif |
|
Set resource limits |
ulimit |
limit |
|
Read from terminal |
read |
$< |
|
Make a variable read-only |
readonly |
set -r |
|
Show possible completions |
Tab |
Tab |
|
Ignore interrupts |
trap 2 |
onintr |
|
Begin |
until/do |
until |
|
Begin |
while/do |
while |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access