Command Forms
|
Syntax |
Effect |
|
|
Execute |
|
|
Command sequence; execute multiple cmds on the same line. |
|
|
Subshell; treat |
|
|
Pipe; use output from |
|
|
Command substitution; use |
|
|
Command substitution; nesting is allowed. |
|
|
AND; execute |
|
|
OR; execute |
|
|
Execute commands in the current shell. |
Examples
$ cd; ls Execute sequentially $ (date; who; pwd) > logfile All output is redirected $ sort file | pr -3 | lp Sort 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 $ egrep '(yes|no)' $(cat list) Same as previous using bash command substitution $ egrep '(yes|no)' $(<list) Same, but faster $ grep XX file && lp file Print file if it contains the pattern $ grep XX file || echo "XX not found" Echo an error message if pattern not found
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