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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 353k
  • Answers 353k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could: cd 1.0.0.1 git init . git add -A… May 14, 2026 at 7:49 am
  • Editorial Team
    Editorial Team added an answer Railscasts are always a good place to start. In particular:… May 14, 2026 at 7:49 am
  • Editorial Team
    Editorial Team added an answer You should either override the event handlers of a TAction… May 14, 2026 at 7:49 am

Related Questions

Are there any good books for a relatively new but not totally new *nix
On my wiki implemented by the MediaWiki interface, I am receiving a Failed to
I need to know the status of a service at the end of my
This appears similar to an earlier post: ld cannot find an existing library But
Microsoft provides a number of command line tools for working with asp.net applications. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.