Skip to main content
added 1 character in body
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165

Let us define foo:

$ foo="*" 

Now, try echo without quotes:

$ echo $foo File1 File2 

The replacement of * with a list of filenames is called pathname expansion. It can be suppressed with with double-quotes:

$ echo "$foo" * 

In addition, double-quotes will prevent _brace expansionbrace expansion, tilde expansion, and word splitting.

For completeness, try echo with single quotes:

*$$ echo '$foo' $foo 

Single quotes prevent the shell from making any substitutions at all.

Let us define foo:

$ foo="*" 

Now, try echo without quotes:

$ echo $foo File1 File2 

The replacement of * with a list of filenames is called pathname expansion. It can be suppressed with with double-quotes:

$ echo "$foo" * 

In addition, double-quotes will prevent _brace expansion, tilde expansion, and word splitting.

For completeness, try echo with single quotes:

*$ echo '$foo' $foo 

Single quotes prevent the shell from making any substitutions at all.

Let us define foo:

$ foo="*" 

Now, try echo without quotes:

$ echo $foo File1 File2 

The replacement of * with a list of filenames is called pathname expansion. It can be suppressed with with double-quotes:

$ echo "$foo" * 

In addition, double-quotes will prevent brace expansion, tilde expansion, and word splitting.

For completeness, try echo with single quotes:

$ echo '$foo' $foo 

Single quotes prevent the shell from making any substitutions at all.

Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165

Let us define foo:

$ foo="*" 

Now, try echo without quotes:

$ echo $foo File1 File2 

The replacement of * with a list of filenames is called pathname expansion. It can be suppressed with with double-quotes:

$ echo "$foo" * 

In addition, double-quotes will prevent _brace expansion, tilde expansion, and word splitting.

For completeness, try echo with single quotes:

*$ echo '$foo' $foo 

Single quotes prevent the shell from making any substitutions at all.