Loading...
Shell Script

Types of Quotes There Rules & Situation

There are two types of quotes. They are (i) Single Quotes (ii) Double Quotes

i) Single Quotes:
In single quotes all the characters including special characters are treated as normal characters. So characters within single quotes are quoted as if a backslash in front of every character.

$echo <-$18000.**>; (update?) [y|n)
-bash: syntax error near unexpected token ‘;’
$echo ‘<-$18000.**>;(update?) [y|n]’
<-$18000.**>;(update?) [y|n]

ii)Double Quotes:
The double quotes (“”) protects everything enclosed between two double quotes marks except $, `, ” and \. Use the double quotes when we want and command substitution.

$echo “$SHELL”
/bin/bash
$echo “/etc/*.conf”
/etc/*.conf
$echo “Today is $(date)”
Today is sat Jan 7 15:20:08 EDT 2017
$echo “Today is `date`”
Today is sat Jan 7 15:20:08 EDT 2017
$echo “$1=Rs.71”
=Rs.50
$echo “\$1=Rs.71”
$1=Rs.50




Leave a Reply

Your email address will not be published. Required fields are marked *