UbuntuShell Study Notes

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.