Echo a Bell Character Cmd

Peter Y. picture Peter Y. · Mar 24, 2018 · Viewed 8k times · Source

At the command prompt in Windows, I can echo a bell character by typing echo and then holding down Ctrl+G to produce echo ^G, and it will make a bell noise when I run it.

When I actually type echo ^G with my keyboard, it will only print G onto the screen and not make any noise.

Can someone explain this?

Thanks

Answer

sgmoore picture sgmoore · Mar 24, 2018

The ^G in the first case is supposed to represent one character which is the Ctrl-G character.

When you are typing ^G you are typing two characters and they are interpreted as two characters.

However the command line treats ^ as a special character to let it know that the next character is to be treated literally, so it is not actually displayed on the screen, so you just see the G.