1

I have two variables declared in shell script

var1=23
var2=27

echo $var1              # Prints 23
echo '$var1'            # Prints $var1
echo "$var1"            # Prints 23

From the above I have some confusion regarding single and double quotes usage on variables.

please can any one clarify this with an example difference between single and double quote.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • What's the confusion? What did you expect to be printed? – John Kugelman Nov 02 '17 at 15:44
  • Iam not getting difference between single and double quotes in the above context . In the above without using quotes it printed 23, with double quotes it printed 23 ,then with single quote it printed as it is. why is that? – PranayReddy Nov 02 '17 at 15:45
  • Start here. http://mywiki.wooledge.org/BashGuide/SpecialCharacters – William Pursell Nov 02 '17 at 15:46
  • If you're asking something covered by preexisting questions, it's helpful to describe *how your question differs* -- that is to say, what you understood those preexisting questions' answers to mean, and what specific points of confusion you still have after reading them. – Charles Duffy Nov 02 '17 at 15:47
  • Or here: https://www.gnu.org/software/bash/manual/html_node/Quoting.html#Quoting – William Pursell Nov 02 '17 at 15:48

0 Answers0