Unix backquote

The backquote ` is used for command substitution.

When the shell encounters a string between backquotes `cmd` it executes cmd and replaces the backquoted string with the standard output of cmd, with any trailing newlines deleted.

Symbol Price Change
GOOG 590.51 8.1
GE 16.71 0.48
MSFT 27.31 0.33
PriceLine=`grep $symbol $pricefile | sed 's/^[A-Z]\{1,\}//'`

set `echo ${PriceLine}`

Bourne shell uses three characters for quoting: single quotes ('), double quotes ("), and backslashes (\).

  • A backslash (\) protects the next character, except if it is a newline. If a backslash precedes a newline, it prevents the newline from being interpreted as a command separator, but the backslash-newline pair disappears completely.

  • Single quotes ('...') protect everything (even backslashes, newlines, etc.) except single quotes, until the next single quote.

  • Double quotes ("...") protect everything except double quotes, backslashes, dollar signs, and backquotes, until the next double quote. A backslash can be used to protect ", \, $, or ` within double quotes. A backslash-newline pair disappears completely; a backslash that does not precede ", \, $, `, or newline is taken literally.