I know that we can use the following syntax to create a for loop in linux or android shell script :
for i in 1 2 3 4 5
do
echo $i
done
It is working as expected when written directly in terminal :
But when the code is saved in a .sh file and called in terminal using the 'sh' command, it shows - "syntax error 'do".
Code in a .sh file :
File called in terminal :
Can anyone explain what exactly is happening here ? I am using Terminal Emulator in android. When I am working with other commands in the .sh file, there is no problem with newline encoding.