Changes

Jump to navigation Jump to search
359 bytes added ,  14:48, 12 September 2009
no edit summary
|"
|Double Quotes
|The double quote ( "quote" ) protects everything enclosed between two double quote marks except $, ', " and \.Use the double quotes when you want only '''variables and command substitution'''.<br/>* '''Variable''' - Yes<br/>* '''Wildcards''' - Yes<br/>* '''Command substitution''' - yes
|The double quotes allowes to print the value of $SHELL variable, disables the meaning of [[wildcards]], and finally allows command substitution.<br/><code>echo "$SHELL"<br/>echo "/etc/*.conf"<br />echo "Today is $(date)"</code><br />&nbsp;
|-
|'
|Single quotes
|The single quote ( 'quote' ) protects everything enclosed between two single quote marks. It is used to '''turn off the special meaning''' of all characters.<br/>* '''Variable''' - No<br/>* '''Wildcards''' - No<br/>* '''Command substitution''' - No
| The single quotes prevents displaying variable $SHELL value, disabled the meaning of [[wildcards]] /etc/*.conf, and finally command substitution ($date) itself. <br/><code>echo '$SHELL'<br/>echo '/etc/*.conf'<br />echo 'Today is $(date)'</code><br />&nbsp;
|-
|`
|Back quote
|Use back quote ( `command-name` ) to '''execute command''' and replace a command with its output within the same command-line. However, ''$(command-name)'' is encouraged syntax for substitution as it is recommended by [[POSIX]] standard and it improves script readability.<br/>* '''Variable''' - Yes<br/>* '''Wildcards''' - Yes<br/>* '''Command substitution''' - yes|The [[date command]] is executed and its output is substituted back to [[echo command]].<br/><code>echo "Today is `date`"<br />echo "Today is $(date)"<br/>echo "$(ls /etc/*.conf)"<br/>FILES=/etc/resolv.conf<br/>echo "$(cat $FILE)"</code><br />&nbsp;
|-
|}

Navigation menu