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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:04:39+00:00 2026-05-15T08:04:39+00:00

When running a bash script on ubuntu 9.10, I get different behavior from bash

  • 0

When running a bash script on ubuntu 9.10, I get different behavior from bash echo’s “-e” option depending on whether or not I’m running as root.

Consider this script:

$ cat echo-test
if [ "`whoami`" = "root" ]; then
  echo "Running as root" 
fi
echo Testing /bin/echo -e
/bin/echo -e "foo\nbar"
echo Testing bash echo -e
echo -e "foo\nbar"

When run as non-root user, I see this output:

$ ./echo-test 
Testing /bin/echo -e
foo
bar
Testing bash echo -e
foo
bar

When run as root, I see this output:

$ sudo ./echo-test 
Running as root
Testing /bin/echo -e
foo
bar
Testing bash echo -e
-e foo
bar

Notice the “-e” being echoed in the last case (“-e foo” instead of “foo” on the second-to-last line). When running a script as root, the echo command runs as if “-e” was given and, if -e is given, the option itself is echoed.

I can understand some subtle differences in behavior between /bin/echo and bash echo, but I would expect bash echo to behave the same no matter which user invokes it.

Anyone know why this is the case? Is this a bug in bash echo?

FYI — I’m running GNU bash, version 4.0.33(1)-release (x86_64-pc-linux-gnu)

  • 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-15T08:04:40+00:00Added an answer on May 15, 2026 at 8:04 am

    are you sure that your user and root both use bash as their shell?
    try putting a “shebang” line (#!/bin/bash) in your script as first line, and run it again

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

Sidebar

Related Questions

When running commands from a bash script, does bash always wait for the previous
I am running a bash script that calls mysql. The password ist not correctly
I'm running a pretty simple bash script in ubuntu but have come up with
I'm having trouble running a simple bash script from Java. Specifically: ... try{ ProcessBuilder
I am running Ubuntu 11.10 (Unity interface) and I created a Bash script that
I am running Ubuntu Precise. In my /etc/init.d I have a bash script that,
I am right now running a bash script in which i need to change
Suppose we have a BASH script running some commands in the background. At some
I have a bash script activated by crontab and running in background. I would
I'm running ArchLinux, kernel 3.4.4, bash version 4.2.29. I downloaded the android sdk from

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.