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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:31:23+00:00 2026-05-13T16:31:23+00:00

I have this script called test.sh: #!/bin/bash STR = Hello World echo $STR when

  • 0

I have this script called test.sh:

#!/bin/bash
STR = "Hello World"
echo $STR

when I run sh test.sh I get this:

test.sh: line 2: STR: command not found

What am I doing wrong? I look at extremely basic/beginners bash scripting tutorials online and this is how they say to declare variables… So I’m not sure what I’m doing wrong.

I’m on Ubuntu Server 9.10. And yes, bash is located at /bin/bash.

  • 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-13T16:31:23+00:00Added an answer on May 13, 2026 at 4:31 pm

    You cannot have spaces around the = sign.

    When you write:

    STR = "foo"
    

    bash tries to run a command named STR with 2 arguments (the strings = and foo)

    When you write:

    STR =foo
    

    bash tries to run a command named STR with 1 argument (the string =foo)

    When you write:

    STR= foo
    

    bash tries to run the command foo with STR set to the empty string in its environment.

    I’m not sure if this helps to clarify or if it is mere obfuscation, but note that:

    1. the first command is exactly equivalent to: STR "=" "foo",
    2. the second is the same as STR "=foo",
    3. and the last is equivalent to STR="" foo.

    The relevant section of the sh language spec, section 2.9.1 states:

    A "simple command" is a sequence of optional variable assignments and redirections, in any sequence, optionally followed by words and redirections, terminated by a control operator.

    In that context, a word is the command that bash is going to run. Any string containing = (in any position other than at the beginning of the string) which is not a redirection and in which the portion of the string before the = is a valid variable name is a variable assignment, while any string that is not a redirection or a variable assignment is a command. In STR = "foo", STR is not a variable assignment.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to open up the Project Explorer view (it… May 17, 2026 at 12:20 am
  • Editorial Team
    Editorial Team added an answer It's a unique id associated with that particular instance of… May 17, 2026 at 12:20 am
  • Editorial Team
    Editorial Team added an answer You can insert the table name and number of rows… May 17, 2026 at 12:19 am

Trending Tags

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

Top Members

Related Questions

For testing purposes I have this shell script #!/bin/bash echo $$ find / >/dev/null
I have a very simple Python file, called python1.py, whose contents are: f =
I have this situation where we have media files stored on a global CDN.
I edited this question after i found a solution... i need to understand why
I am using a Perl module called from a CGI scipt in IIS 6
We have a staging version of our web application (it is basically a subversion
I asked a similar question over here:( Upload clocking script ), but then changed
I am trying to test the Cybersource 3d party implementation. I was able to
I have a java program that I am trying to generate 3 outputs for,
i have put in a css box colored red and for some reason the

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.