This error occurs because some Linux systems use Ash to compile shell scripts by default, as is my machine, but the scripts I write should be executed with bash. Although I noted in the beginning #!/bin/bash, as if it is still the default to find Ash, it is very frustrating. Search the internet for a bit, find two solutions: 1, modify script 2, modify the system default execution Shell tool
The first kind of practice is that the original for loop is similar to this for ((I=1; i<3; i++)) and changed to something like this: for I in ' seq 1000 ', which was copied from a Netizen's blog, I don't know if it's equivalent. But look at the latter full face black question mark, after all, I write more Java, so I do not know what the latter mean.
The second way to do this is to execute a command sudo dpkg-reconfigure dash, after executing this command there will be a scary page, full-screen background to red, a hint box. The idea is that our system chooses dash by default to improve the system's performance and boot speed (as if there is one), choose Dash as the default execution Shell tool? (PIT) We can choose the no option. I did not dare to choose, because I do not know what will be a moth after the election.
But after writing this, I am ready to change, because I have a lot of in the original for the loop, I do not know how to change them to bash execution of the way.
OK, if you change and then want to change back, directly re-execute the above command, choose Yes. Easy
Syntax error for the For loop in the shell (syntax Error:bad for loop variable)