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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:41:56+00:00 2026-05-26T22:41:56+00:00

Im having trouble with cygwin not running my script file as expected here is

  • 0

Im having trouble with cygwin not running my script file as expected

here is my code

#!/bin/sh
echo "Ja eller nei:"
read svar
if ["$svar" = "ja"]; then
    echo "Du er Positiv"
    exit 0
elif ["$svar" = "nei"]; then
    echo "Du er Negativ"
    exit 0
else
    echo "Du er Nøytral"
fi

and here is my outputin cygwin

$ /cygdrive/c/MyScripts/Bash.sh
Ja eller nei:
ja
': not a valid identifierh.sh: line 6: read: `svar
/cygdrive/c/MyScripts/Bash.sh: line 10: syntax error near unexpected token `elif'
'cygdrive/c/MyScripts/Bash.sh: line 10: `elif ["$svar" = "nei"]; then

its the 3 last error lines i dont understand per say. i understand where the error’s are but not why they are there.

BTW the reason im saying some is

for i in {1..100}; do echo $i; done

works properly

  • 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-26T22:41:57+00:00Added an answer on May 26, 2026 at 10:41 pm

    Try forming your test statements with correct spacing:

    #!/bin/sh
    echo "Ja eller nei:"
    read svar
    if [ "$svar" = "ja" ]; then
        echo "Du er Positiv"
        exit 0
    elif [ "$svar" = "nei" ]; then
        echo "Du er Negativ"
        exit 0
    else
        echo "Du er Nøytral"
    fi
    

    This is the output I get:

    lnet@bowser ~ $:) sh test.sh
    Ja eller nei:
    ja
    Du er Positiv
    lnet@bowser ~ $:) sh test.sh
    Ja eller nei:
    nei
    Du er Negativ
    lnet@bowser ~ $:) sh test.sh
    Ja eller nei:
    fish
    Du er N[G[Gøytral
    lnet@bowser ~ $:(
    

    Update (thanks Sorpigal):

    Also, make sure your file has proper unix line endings:

    dos2unix -f /cygdrive/c/MyScripts/Bash.sh
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble running the script below (in Cygwin on win 7 mind
Having trouble here and not quite sure how to do it. I've attempted jQuery
I'm having trouble with a shell script in Cygwin. The specific command that's causing
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having trouble with the following segment of code. I'm getting a parameter count mismatch.
Im having trouble reading from a CSV file final String DELIMITER = ,; Scanner
having trouble with this. i need to come up with a logic code. How
Having trouble getting my JQuery POST to be accepted by the WCF Service. Here's
Having trouble rewriting the name of a flash file: /flash/shell.1257347618.swf (the numbers are a

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.