1、Compound commands
Grouping
{ …; }
( … )
command grouping in a subshell
Conditionals
[[ ... ]]
if …; then …; fi
case … esac
Loops
for word in …; do …; done
for ((x=1; x<=10; x++)); do ...; done
while …; do …; done
until …; do …; done
Misc
(( ... ))
select word in …; do …; done
2、Expansions and substitutions
Introduction to expansions and substitutions
{A,B,C} {A..C}
~/ ~root/
$FOO ${BAR%.mp3}
`command` $(command)
<(command) >(command)
$((1 + 2 + 3)) $[4 + 5 + 6]
Hello <---> Word!
/data/*-av/*.mp?
3、Builtin Commands
Declaration commands
Commands that set and query attributes/types, and manipulate simple datastructures.
Alt
Type
Display or set shell variables or functions along with attributes.
typeset
builtin
Display or set shell variables, also giving them the export attribute.
-
special builtin
A common misspelling of "evil"
-
special builtin
Declare variables as having function local scope.
-
builtin
Mark variables or functions as read-only.
declare -r
special builtin
Unset variables and functions.
-
special builtin
Shift positional parameters
-
special builtin
Control flow and data processing
Commands that operate on data and/or affect control flow.
Alt
Type
"true" null command
true
special builtin
Source external files
source
special builtin
Fail at doing nothing
-
builtin
continue with or break out of loops.
-
special builtin
Arithmetic evaluation - an old fashioned way.
-
builtin
Break out of a function, returning the specified exit status.
-
special builtin
The classic test
command.
test
builtin
Process and Job control
Commands related to jobs, signals, process groups, subshells.
Alt
Type
Replace the shell, set redirections.
-
special builtin
Exit the shell.
-
special builtin
Set traps.
-
special builtin
Display process times.
-
special builtin
Wait for background jobs and asynchronous lists.
-
builtin
I/O
Commands for reading/parsing input, or producing/formatting output of standard streams.
Alt
Type
Co-processes: Run a compound command in the background with async I/O.
-
keyword
Create output from args.
-
builtin
Create arrays from lines of input
readarray
builtin
"advanced echo
."
-
builtin
Build variables or arrays from input streams.
-
builtin
Configuration and Debugging
Commands that modify shell behavior, change special options, assist in debugging.
Alt
Type
Identify/print execution frames.
-
builtin
Control positional parameters and shell behaviour.
-
special builtin
set/get shell options.
-
builtin