Skip to main content
edited tags
Link
ilkkachu
  • 148k
  • 16
  • 268
  • 441
Source Link
user268325
  • 235
  • 2
  • 4

Enclosing vs. not enclosing a variable's value in quotes in bash

When I do something like this:

x="hi echo hello" 

or

x='hi echo hello' 

Then x will contain the string hi echo hello.

But when I don't use quotes:

x=hi echo hello 

Then x will contain the string hi, and the command echo hello will be executed.


But what about when a variable's value only consists of a single word, is there a difference between the following:

x="hi" x='hi' x=hi