|
sh |
bash |
ksh |
csh |
Meaning/Action |
$ |
$ |
$ |
% |
Default user prompt |
|
>| |
>| |
>! |
Force redirection |
> file 2>&1 |
&> file or > file 2>&1 |
> file 2>&1 |
>& file |
Redirect stdout and stderr to file |
|
{ } |
|
{ } |
Expand elements in list |
`command` |
`command` or $(command) |
$(command) |
`command` |
Substitute output of enclosed command |
$HOME |
$HOME |
$HOME |
$home |
Home directory |
|
~ |
~ |
~ |
Home directory symbol |
|
~+, ~-, dirs |
~+, ~- |
=-, =N |
Access directory stack |
var=value |
VAR=value |
var=value |
set var=value |
Variable assignment |
export var |
export VAR=value |
export var=val |
setenv var val |
Set environment variable |
|
${nnnn} |
${nn} |
|
More than 9 arguments can be referenced |
"$@" |
"$@" |
"$@" |
|
All arguments as separate words |
$# |
$# |
$# |
$#argv |
Number of arguments |
$? |
$? |
$? |
$status |
Exit status of the most recently executed command |
$! |
$! |
$! |
|
PID of most recently backgrounded process |
$- |
$- |
$- |
|
Current options |
. file |
source file or . file |
. file |
source file |
Read commands in file |
|
alias x='y' |
alias x=y |
alias x y |
Name x stands for command y |
case |
case |
case |
switch or case |
Choose alternatives |
done |
done |
done |
end |
End a loop statement |
esac |
esac |
esac |
endsw |
End case or switch |
exit n |
exit n |
exit n |
exit (expr) |
Exit with a status |
for/do |
for/do |
for/do |
foreach |
Loop through variables |
|
set -f, set -o nullglob|dotglob|nocaseglob|noglob |
|
noglob |
Ignore substitution characters for filename generation |
hash |
hash |
alias -t |
hashstat |
Display hashed commands (tracked aliases) |
hash cmds |
hash cmds |
alias -t cmds |
rehash |
Remember command locations |
hash -r |
hash -r |
|
unhash |
Forget command locations |
|
history |
history |
history |
List previous commands |
|
ArrowUp+Enter or !! |
r |
!! |
Redo previous command |
|
!str |
r str |
!str |
Redo last command that starts with "str" |
|
!cmd:s/x/y/ |
r x=y cmd |
!cmd:s/x/y/ |
Replace "x" with "y" in most recent command starting with "cmd", then execute. |
if [ $i -eq 5 ] |
if [ $i -eq 5 ] |
if ((i==5)) |
if ($i==5) |
Sample condition test |
fi |
fi |
fi |
endif |
End if statement |
ulimit |
ulimit |
ulimit |
limit |
Set resource limits |
pwd |
pwd |
pwd |
dirs |
Print working directory |
read |
read |
read |
$< |
Read from terminal |
trap 2 |
trap 2 |
trap 2 |
onintr |
Ignore interrupts |
|
unalias |
unalias |
unalias |
Remove aliases |
until |
until |
until |
|
Begin until loop |
while/do |
while/do |
while/do |
while |
Begin while loop |
|
|