Declare in Ubuntu

Source: Internet
Author: User
In the shell execution of Ubuntu, the user root is different from the common user. Using vi/etc/passwd, we can see that the root location is/bin/bash in the last line of the user, that is, the location where shell execution is defined, while other users are/bin/sh. therefore, the bashtest should be used when the root user executes scipt In Ubuntu. sh (note that in linux, there is no file suffix added only to identify special files. Whether the file can run the master

In the shell execution of Ubuntu, the user root is different from the common user. Using vi/etc/passwd, we can see that the root location is/bin/bash in the last line of the user, that is, the location where shell execution is defined, while other users are/bin/sh.

Therefore, in Ubuntu, it should be bash test. sh when the root node executes scipt (note that there is no file extension in linux, and it is only used to identify special files. Whether the file can be executed depends on whether x in the file attribute is opened North) rather than sh test. sh.

#! /Bin/bash

Declare-I number2 = 10 + 100 + 1000

Echo "Your result is $ number1"

...:~ $ Sh test03-declare.sh

Test03-declare.sh: 5: declare: not found

...:~ $ Bash test03-declare.sh

...:~ $ Your result is 1110

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.