0

I have this simple for loop

#!/bin/bash
for number in {1..10}   
    do
        echo $number
    done

but when I execute it with sh test.sh the output is

{1..10}
What is wrong?

1 Answer 1

4

You declare at the top that the script uses bash and run it with sh.

If you just type this in the command line it will work:

./name_of_the_script

Alternatively, you can call on the bash interpreter explicitly:

bash name_of_the_script
Sign up to request clarification or add additional context in comments.

2 Comments

What is the way to execute it with sh?,Thank you.
Use correct sh syntax: for i in $(seq 1 10); do echo $i done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.