- Single quote '
Like
$echo 'two rabits'
two rabits
When we execute the following command, we would see the annoying thing. The * is replaced by the file names in the current directory and it's not the result we would like to see.
$i='* is an asterisk'
$echo $i
load.ctl load.txt load.log is an asterisk
To overcome this, we can make use of double quotes.
- Double quote "
Single quote ignores all the special characters while double quote ignores most. The following three characters are not ignored by double quotes. They are Dollar sign $, back quote `, and backslash \ .
Here is the example:
$i='* is an asterisk"
$echo "$i"
* is an asterisk
- Backslash \
Shell ignores any special meaning attached to a character by using a backslash before this character.
$i=>
-ksh: syntax error: `new line` unexpected
$i=\>
$echo $i
>
When processing a long command, backslash can also be used for continuing lines.
$i=one\
>two
$echo $i
onetwo
- Back quote `
Back quote tells shell to execute the command enclosed by it. However, it's an old command and not preferred for use.+
$echo current date is `date`
current date is Wed Apr 16 13:02:59 CEST 2014
Instead of Back quote, we use $(...) construct to substitute command and output to the command line.
$echo current date is $(date)
current date is Wed Apr 16 13:02:59 CEST 2014
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13738922/viewspace-1143554/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13738922/viewspace-1143554/