Shell variable problems-general Linux technology-Linux technology and application information, the following is a detailed description. [I = s] This post was last edited by theegg at, January 11 ,.
I have two shell files
1. main. sh
_ Active = 10; # value assignment
. Function. sh # Call the function File
Change_var # execution function
2. function. sh
Change_var (){
_ Active = 200;
}
I run main. sh
Why is the value of _ active not changed?
========================================================== ===
Thank you for your answers.
I will describe the problem in detail, because I was just learning shell and may not be able to describe it well.
1. I want to make a command to integrate all common commands, such as./ben. sh db-a add-d 'dbname ',
2. File structure
~ /Ben. sh
~ /Include/function/init. sh
~ /Include/function/db. sh
~ /Logs/
3. File Code
4. Problem
When I run the./ben. sh db-a add-d test, _ db_active variable, the value cannot be obtained through the parameter. The same is true for other parameters. This variable is defined in the starting script. Can I assign a value in a subscript?
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