Q.Fix the broken script so that it prints the numbers 1 to 10 like the other scripts.
→ following script had error
#!/bin/sh
echo {1…10}
By changing shebang to #!/bin/bash, issue was resolved. But why is this?? Pls explain
i didnt understand, can u explain?
bash is a more advanced shell than sh - it has more syntax, and is like an upgrade to sh
{1…10} is is just a string of characters in sh and echo will print exactly that.
To get the same output as bash using sh you must use the external program seq
#!/bin/sh
echo "$(seq -s " " 1 10)"