Monday, May 26, 2008

The mystery of quotes

In linux environment, there are 3 types of quotes as far as i know. Each of the quotes bring different meaning and usage.
  1. ' a.k.a. single quotes - Everything wrapped in this quote won't be changed (Strong quotes)
  2. " a.k.a. double quotes - Quotes that doesn't expand meta-characters like "*" or "?," but does expand variables and does command substitution (Weaker quotes)
  3. ` a.k.a. back quotes - To execute command
Examples of quotes usage (top lines are commands and the output are displayed below the commands):

Example of using back quotes within single quotes. Nothing is changed.
$ echo 'Today is `date`'
Today is `date`

Example of using back quotes within double quotes. The `date` command will be executed
$ echo "Today is `date`"
Today is Mon May 26 09:42:50 MYT 2008

No comments:

Post a Comment