-1

I have a basic question about Shell interpretation

When i make something like :

echo "#!/bin/bash"

-bash: !/bin/bash: event not found

What does the shell really pass to the echo command. If i understand well, the double quote make the shell doesnt do globbing.

Community
  • 1
  • 1
khaled83
  • 29
  • 3

1 Answers1

0

! is used for history expansion, not for globbing.

From the bash documentation:

Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of $, `, \, and, when history expansion is enabled, !.

jhnc
  • 11,310
  • 1
  • 9
  • 26
  • Note the bullet point in the "Answer Well-Asked Questions" section of [How to Answer](https://stackoverflow.com/help/how-to-answer) regarding questions which "have already been asked and answered many times before". – Charles Duffy Jul 29 '19 at 21:23
  • sorry @CharlesDuffy, I should have checked. Should I delete this answer? – jhnc Jul 29 '19 at 21:57
  • No obligation to. Personally, what I usually do when I discover that I answered a duplicate (where it's a simple enough question that there won't be a huge amount of extra benefit to someone clicking through and reading the preexisting canonical answers) is toggle the "community wiki" flag, but that too isn't obligatory. – Charles Duffy Jul 30 '19 at 00:03