Use sh-x & lt; script-name & gt; In Ubuntu to debug a shell script. It is found that shell does not support the following forloopfor (expr1; expr2; expr3 )) after searching for the following online, we found that the default shell of Ubuntu is not the default bash, But dash, as shown below: fly @ fly-laptop :~ $ Whichsh/bin/shfly @ fly-lap
Use sh-x in Ubuntu Debug a shell script and find that shell does not support the following for loop
For (expr1; expr2; expr3) Searches the Internet and finds that the default shell of Ubuntu is not the default bash, but uses dash, as shown below
Fly @ fly-laptop :~ $ Which sh
/Bin/sh
Fly @ fly-laptop :~ $ Ls-l/bin/sh
Lrwxrwxrwx 1 root 4 2010-07-06 04:50/bin/sh-> dash
To change the default shell back to bash, run sudo dpkg-reconfigure dash on the terminal and select no.
However, the default settings of Ubuntu are not modified. Use/bin/bash-x instead. Substitution
However, it is a little strange to use ./ Run the shell script and find that the above problem does not exist. Isn't this the case of calling dash shell, confused.
You can also use bashdb to debug shell scripts. If you want to use IDE, try ddd -- debugger/usr/bin/bashdb.