Command Forms
|
Command |
Action |
|
|
Execute cmd in the background. |
|
|
Command sequence; execute multiple cmds on the same line. |
|
|
Subshell; treat cmd1 and cmd2 as a command group. |
|
|
Pipe; use output from cmd1 as input to cmd2. |
|
|
Command substitution; run cmd2 first and use its output as arguments to cmd1. |
|
|
AND; execute cmd1 and then (if cmd1 succeeds) cmd2. This is a “short-circuit” operation; cmd2 is never executed if cmd1 fails. |
|
|
OR; execute either cmd1 or (if cmd1 fails) cmd2. This is a “short-circuit” operation; cmd2 is never executed if cmd1 succeeds. |
Examples
%nroff file > file.out &Format in the background %cd; lsExecute sequentially %(date; who; pwd) > logfileAll output is redirected %sort file | pr -3 | lpSort file, page output, then print %vi 'grep -l ifdef *.c'Edit files found by grep %egrep '(yes|no)' 'cat list'Specify a list of files to search %grep XX file && lp filePrint file if it contains the pattern, %grep XX file || echo XX not foundotherwise, echo an error message
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