Text-only Table of Contents (frame/ no frame)
(13) Command substitution Previous Top Next

Command Substitution

sh syntax

`command`
A command (plus optional arguments) enclosed in backticks is executed and the standard output of that command is substituted. If the command produces multiline output, the newlines are retained. If the resultant string is displayed, unquoted, using echo, newlines and multiple spaces will be removed.

ksh/bash syntax

$(command)
This syntax is functionally the same as backticks, but commands can be more easily nested.
$(<file)
This is equivalent to `cat file`, but implemented internally for efficiency.

Example: ex3 display, text


Previous Top Next


command-subs.src  last modified Mar 11, 2005 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College