Echo Command and Quoting in Linux


Echo Command With Examples


The echo command writes character strings to standard output. Strings are separated by spaces, and a new-line character follows the last String parameter specified. If no String parameter is specified, a blank line (new-line character) is displayed.

Example:


Here x is assigned as 52

x=52


and foo is substituted as value of x

foo=$x

Now see what the output of echo is


echo command and quoting


without quoting


$ echo hello
hello

$ echo $hello
52

$ Echo ${hello}
52

Using double quote


$ echo “$hello”
52

$ echo “${hello}”
52

Using single quote

$ echo '$hello'
$hello

$ echo '${hello}'
${hello}


Let

$ hello= “Hi Wor   l   d”
$ echo $hello
Hi Wor l d

$ echo “$hello”
Hi Wor   l   d


$ echo ‘$hello’
$hello



No comments: