bash string with/without quote and single/double q

2019-09-13 19:38发布

问题:

This question already has an answer here:

  • Difference between single and double quotes in Bash 6 answers
  • When to wrap quotes around a shell variable? 5 answers
$ volume=vol1
$ echo $volume 
vol1

$ volume="vol1"
$ echo $volume 
vol1

$ volume='vol1'
$ echo $volume 
vol1

What is the difference between the above in bash scripting? All are one and same?

回答1:

You'll probably find the definitive answer on that wiki.

Short answer: the quote are needed arround $volume.