BASH and YES or ECHO cannot send "!"

Nix, Robert P. Nix.Robert at
Tue Dec 13 17:52:00 UTC 2005

-----Original Message-----
From: fedora-list-bounces at [mailto:fedora-list-bounces at] On Behalf Of Mike McCarty
Sent: Tuesday, December 13, 2005 11:40 AM
To: For users of Fedora Core releases
Subject: BASH and YES or ECHO cannot send "!"

I have come across an interaction between bash and yes or echo.

$ echo "Hello there!"
bash: !": event not found
$ echo "Hello there\!"
Hello there\!

So there seems not to be a way to display that string.

Oh, wait, apostrophes work!

$ echo 'Hello there!'
Hello there!

<end quote>

! Is a reserved symbol in bash, and it uses it for so many different things that it's not surprising that it would be difficult to get a real one past the parser. Note that \! is reserved as well. Since things quoted in double quotes get pushed back through the parser, the easiest way to get around that would be to use single quotes (which you pointed out will work).

Robert P. Nix		Mayo Foundation
RO-OC-1-13 (new loc)	200 First Street SW
507-284-0844		Rochester, MN 55905
"In theory, theory and practice are the same, but
 in practice, theory and practice are different."

More information about the fedora-list mailing list