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 8792579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:59:54+00:00 2026-06-13T22:59:54+00:00

Very similar to this question . I’m iterating through a few things with an

  • 0

Very similar to this question.

I’m iterating through a few things with an automated script in BASH. Occasionally the script will come across "-n" and echo will attempt to interpret this.

Attempted this:

 $ POSIXLY_CORRECT=1 /bin/echo -n

and

 $ POSIXLY_CORRECT=1 /bin/echo "-n"

 

But it interpreted the argument each time.

Then this, which works but it’s possible to hit escaped characters in the strings, which is why I don’t want to apply a null character to all input and use -e.

$ echo -e "\x00-n"
-n

printf is possible, but is to be avoided unless there are no other options (Not all machines have printf as a utility).

$ printf "%s" "-n"
-n

So is there a way to get echo to print "-n"?

  • 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-06-13T22:59:55+00:00Added an answer on June 13, 2026 at 10:59 pm

    printf should be a built-in in all your shells, unless some of your machines have very old shell versions. It’s been a built-in in bash for a long time. It’s probably more portable than echo -e.

    Otherwise, there’s really no way to get echo options it cares about.

    Edit: from an answer to another similar question; avoid quoting issues with printf by using this handy no-digital-rights-retained wrapper:

    ech-o() { printf "%s\n" "$*"; }
    

    (That’s ech-o, as in “without options”)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My requirement is very much similar to this question . Basically, I will be
My question is very similar to this question - Addin parameter for Oracle except
This question is very similar (or almost identical) to In a non blocking socket
I know that this question is very similar to the question posted here .
This question is very similar to an earlier question I asked ( This Question
This is a very similar question to this SO thread on middleware and views
I had asked a question very much similar to this in the thread: https://stackoverflow.com/questions/11259474/store-the-numericals-in-char-array-into-an-integer-variable-in-vc
This is very similar to another recent question: How can I return the current
This is very similar to a previous question (and may be the exact same
My question popped up a very similar question, this one . But the accepted

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.