Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Exclamation Mark as a command line argument

  • 02-09-2005 09:36AM
    #1
    Registered Users, Registered Users 2 Posts: 3,890 ✭✭✭


    In bash, how do I do
    echo "Hello World!"
    
    without the ! being interpreted as having a command history meaning, which is what I assume is happening here...
    # echo "hello world!"
    bash: !": event not found
    

    ... ta

    .cg


Comments

  • Closed Accounts Posts: 95 ✭✭krinDar


    echo 'Hello world!'
    

    If you use single quotes the special character (in this case '!') will not be interpreted.

    Another method is to escape the exclamation mark:
    echo Hello world \!
    

    Again this will prevent the shell from interpreting the special character.


  • Registered Users, Registered Users 2 Posts: 3,890 ✭✭✭cgarvey


    Cool, ta muchly!


Advertisement