Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 723033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:03:37+00:00 2026-05-14T06:03:37+00:00

My knowledge of commandline bash is missing on a particular area: I constantly forget

  • 0

My knowledge of commandline bash is missing on a particular area: I constantly forget how to properly escape characters. Today I wanted to echo this string into a file:

#!/bin/env bash
python -m SimpleHTTPServer

However, this fails:

echo "#!/bin/env bash\npython -m SimpleHTTPServer" > server.sh && chmod +x server.sh

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

That’s right: Remember to escape ! or bash will think it’s a special bash event command.

But I can’t get the escaping right! \! yields \! in the echoed string, and so does \\!.

Furthermore, \n will not translate to a line break.

Do you have some general tips that makes it easier for me to understand escaping rules?

To be very precise, I’ll accept an answer which tells me which characters I should escape on the bash command line? Including how to correctly output newline and exclamation mark in my example.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:03:38+00:00Added an answer on May 14, 2026 at 6:03 am

    Single quotes inhibit all escaping and substitution:

    echo '$hello world!'
    

    You can alternate or disable quoting if you need to mix things up:

    echo '$5.00 on '"$horse"'!'
    ls -ld ~/'$$'/*
    

    Interpreting escapes is also easy:

    echo $'Wake up!\7'
    sort -n <<< $'4\n3\n8'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My knowledge of matlab is merely on a need to know basis, so this
This isn't strictly a programming question, but hopefully someone here has the knowledge to
I am not strong on my PHP knowledge, but I have never seen this
I'm a PHP developer with little knowledge of bash commands and general use of
My knowledge about implementing a parser is a bit rusty. I have no idea
It's common knowledge that using System.Diagnostics.Process.Start is the way to launch a url from
I have little knowledge of Flash but for a little Flash game I have
We have developers with knowledge of these languages - Ruby , Python, .Net or
In my knowledge, the RESTful WCF still has .svc in its URL. For example,
I have limited knowledge of Java-based technologies, and for business enforced reasons, I may

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.