z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Using quotation marks to enclose a construct in a shell script

z/OS UNIX System Services User's Guide
SA23-2279-00

A $N construct in a shell script can be enclosed in double or single quotation marks.
  • When double quotation marks are used, the parameter is replaced by the appropriate value from the command line. For example, suppose that the file search contains:
    grep "$1" *
    If you enter the command:
    search 'two words'
    the parameter value 'two words' replaces the construct $1 in the grep command:
    grep "two words" *
    If the grep command does not contain the double quotation marks, the parameter replacement would result in:
    grep two words *
    which has an entirely different meaning.
  • When you use single quotation marks to enclose a $N construct in a shell script, the $N is not replaced by the corresponding parameter value. For example, if the file search contains:
    grep '$1' *
    grep searches for the string $1. The $1 is not replaced by a value from the command line. In general, single quotation marks are “stronger” than double quotation marks.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014